Skip to content

Commit

Permalink
Merge branch 'base'
Browse files Browse the repository at this point in the history
  • Loading branch information
goldworm committed Jan 12, 2021
2 parents f05f7d6 + dab4c52 commit 3eae825
Show file tree
Hide file tree
Showing 57 changed files with 620 additions and 353 deletions.
5 changes: 3 additions & 2 deletions cmd/eetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ func (cc *callContext) GetBalance(addr module.Address) *big.Int {
return big.NewInt(state.GIGA)
}

func (cc *callContext) OnEvent(score module.Address, indexed, data [][]byte) {
fmt.Printf("CallContext.OnEvent(%s,%+v,%+v)\n", score, indexed, data)
func (cc *callContext) OnEvent(addr module.Address, indexed, data [][]byte) error {
fmt.Printf("CallContext.OnEvent(%s,%+v,%+v)\n", addr, indexed, data)
return nil
}

func (cc *callContext) OnResult(status error, steps *big.Int, result *codec.TypedObj) {
Expand Down
2 changes: 1 addition & 1 deletion javaee/exec/test/java/foundation/icon/ee/CodecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void run() {

@Test
public void test() {
var score = sm.deploy(new Class<?>[]{Score.class, User.class});
var score = sm.mustDeploy(new Class<?>[]{Score.class, User.class});
score.invoke("run");
}
}
16 changes: 8 additions & 8 deletions javaee/exec/test/java/foundation/icon/ee/CompilerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class CompilerTest extends GoldenTest {
@Test
public void testNoInit() {
sm.deploy(ScoreWithoutInit.class);
sm.mustDeploy(ScoreWithoutInit.class);
}

public static class ScoreWithoutInit {
Expand All @@ -20,7 +20,7 @@ public static class ScoreWithoutInit {
@Test
public void testMultipleInits() {
try {
sm.deploy(ScoreWithMultipleInits.class, "Hello");
sm.mustDeploy(ScoreWithMultipleInits.class, "Hello");
fail();
} catch (ABICompilerException e) {
System.err.println("Expected " + e.getMessage());
Expand All @@ -35,13 +35,13 @@ public ScoreWithMultipleInits(String s) {}
@Test
public void testMultipleSameNames() {
try {
sm.deploy(ScoreWithMultipleSameExternals.class);
sm.mustDeploy(ScoreWithMultipleSameExternals.class);
fail();
} catch (ABICompilerException e) {
System.err.println("Expected " + e.getMessage());
}
try {
sm.deploy(ScoreWithMultipleSameEvents.class);
sm.mustDeploy(ScoreWithMultipleSameEvents.class);
fail();
} catch (ABICompilerException e) {
System.err.println("Expected " + e.getMessage());
Expand All @@ -65,13 +65,13 @@ void sameEvent(String a, String b) {}
@Test
public void testParamType() {
try {
sm.deploy(ScoreWithFloatParam.class);
sm.mustDeploy(ScoreWithFloatParam.class);
fail();
} catch (ABICompilerException e) {
System.err.println("Expected " + e.getMessage());
}
try {
sm.deploy(ScoreWithDoubleParam.class);
sm.mustDeploy(ScoreWithDoubleParam.class);
fail();
} catch (ABICompilerException e) {
System.err.println("Expected " + e.getMessage());
Expand All @@ -91,13 +91,13 @@ public void methodDouble(double d) {}
@Test
public void testReturnType() {
try {
sm.deploy(ScoreWithFloatReturn.class);
sm.mustDeploy(ScoreWithFloatReturn.class);
fail();
} catch (ABICompilerException e) {
System.err.println("Expected " + e.getMessage());
}
try {
sm.deploy(ScoreWithDoubleReturn.class);
sm.mustDeploy(ScoreWithDoubleReturn.class);
fail();
} catch (ABICompilerException e) {
System.err.println("Expected " + e.getMessage());
Expand Down
16 changes: 8 additions & 8 deletions javaee/exec/test/java/foundation/icon/ee/DeployTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ public interface Interface {

@Test
public void test() {
sm.deploy(NoConstructor.class);
sm.mustDeploy(NoConstructor.class);
var e = assertThrows(TransactionException.class,
() -> sm.deploy(PackagePrivateConstructor.class));
() -> sm.mustDeploy(PackagePrivateConstructor.class));
assertEquals(Status.IllegalFormat, e.getResult().getStatus());
e = assertThrows(TransactionException.class,
() -> sm.deploy(ProtectedConstructor.class));
() -> sm.mustDeploy(ProtectedConstructor.class));
assertEquals(Status.IllegalFormat, e.getResult().getStatus());
e = assertThrows(TransactionException.class,
() -> sm.deploy(PrivateConstructor.class));
() -> sm.mustDeploy(PrivateConstructor.class));
assertEquals(Status.IllegalFormat, e.getResult().getStatus());
e = assertThrows(TransactionException.class,
() -> sm.deploy(Abstract.class));
() -> sm.mustDeploy(Abstract.class));
assertEquals(Status.IllegalFormat, e.getResult().getStatus());
e = assertThrows(TransactionException.class,
() -> sm.deploy(Interface.class));
() -> sm.mustDeploy(Interface.class));
assertEquals(Status.IllegalFormat, e.getResult().getStatus());
}

Expand All @@ -77,10 +77,10 @@ public void run() {
@Test
void testClassAccess() {
Assertions.assertDoesNotThrow(() ->
sm.deploy(new Class<?>[]{ClassAccess.class, Inf.class})
sm.mustDeploy(new Class<?>[]{ClassAccess.class, Inf.class})
);
Assertions.assertDoesNotThrow(() ->
sm.deploy(new Class<?>[]{ArrayClassAccess.class, Inf.class})
sm.mustDeploy(new Class<?>[]{ArrayClassAccess.class, Inf.class})
);
}
}
2 changes: 1 addition & 1 deletion javaee/exec/test/java/foundation/icon/ee/EventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void logEvent(boolean a0, byte a1, char a2, short a3, int a4,

@Test
void testLogEvents() {
var score = sm.deploy(Score.class);
var score = sm.mustDeploy(Score.class);
score.invoke("logEvent", true, 1, 2, 3, 4, 5, 6, "7",
sm.newExternalAddress(), new byte[]{0, 1, 2, 3});
}
Expand Down
4 changes: 2 additions & 2 deletions javaee/exec/test/java/foundation/icon/ee/ExceptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void run(Address addrGood, Address addrBad) {

@Test
public void test() {
var score = sm.deploy(Score.class);
var revertScore = sm.deploy(RevertScore.class);
var score = sm.mustDeploy(Score.class);
var revertScore = sm.mustDeploy(RevertScore.class);
score.invoke("run", revertScore.getAddress(), sm.newScoreAddress());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class FeeSharingTest extends GoldenTest {
@Test
void test() {
var owner = sm.getOrigin();
var score = sm.deploy(FeeSharing.class);
var score = sm.mustDeploy(FeeSharing.class);
assertEquals(BigInteger.ZERO, score.query("getProportion", owner).getRet());
String value = "No value";
assertEquals(value, score.query("getValue").getRet());
Expand Down
12 changes: 6 additions & 6 deletions javaee/exec/test/java/foundation/icon/ee/IntercallRefTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,24 @@ public void method(int ttl, boolean ok, @Optional Address addr) {

@Test
public void testRef1() {
var app1 = sm.deploy(RefScoreA.class);
var app2 = sm.deploy(RefScoreB.class);
var app1 = sm.mustDeploy(RefScoreA.class);
var app2 = sm.mustDeploy(RefScoreB.class);
app1.invoke("method", 1, true, app2.getAddress());
}

@Test
public void testRef2() {
var app1 = sm.deploy(RefScoreA.class);
var app2 = sm.deploy(RefScoreB.class);
var app1 = sm.mustDeploy(RefScoreA.class);
var app2 = sm.mustDeploy(RefScoreB.class);
app1.invoke("method", 2, true, app2.getAddress());
}

@Test
public void testRef3() {
createAndAcceptNewJAVAEE();
var app1 = sm.deploy(RefScoreA.class);
var app1 = sm.mustDeploy(RefScoreA.class);
sm.setIndexer((addr) -> 1);
var app2 = sm.deploy(RefScoreB.class);
var app2 = sm.mustDeploy(RefScoreB.class);
sm.setIndexer((addr) -> {
if (addr.equals(app1.getAddress())) {
return 0;
Expand Down
8 changes: 4 additions & 4 deletions javaee/exec/test/java/foundation/icon/ee/IntercallTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public void mvoid() {

@Test
public void testTypes() {
var papp = sm.deploy(TypeTest.Score.class);
var app = sm.deploy(ProxyScore.class, papp.getAddress());
var papp = sm.mustDeploy(TypeTest.Score.class);
var app = sm.mustDeploy(ProxyScore.class, papp.getAddress());
app.invoke("mbyte", 0);
app.invoke("mshort", 0);
app.invoke("mint", 0);
Expand Down Expand Up @@ -137,8 +137,8 @@ public int getValue() {

@Test
public void testFail() {
var app1 = sm.deploy(ScoreA.class);
var app2 = sm.deploy(ScoreFail.class);
var app1 = sm.mustDeploy(ScoreA.class);
var app2 = sm.mustDeploy(ScoreFail.class);
app1.invoke("method", app2.getAddress());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void run() {

@Test
void testBadParam() {
var c = sm.deploy(BadParam.class);
var c = sm.mustDeploy(BadParam.class);
var res = c.invoke("run");
Assertions.assertEquals(0, res.getStatus());
}
Expand Down
2 changes: 1 addition & 1 deletion javaee/exec/test/java/foundation/icon/ee/JCFTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Map<String, Map<String, List<Integer>>> returnMap2() {

@Test
public void test() {
var score = sm.deploy(Score.class);
var score = sm.mustDeploy(Score.class);
score.invoke("run");
score.invoke("dumpMyMap");
score.invoke("setMyMap1");
Expand Down
2 changes: 1 addition & 1 deletion javaee/exec/test/java/foundation/icon/ee/KVDBStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void set2(byte[] v1, byte[] v2) {

@Test
void testSetStepCharge() {
var score = sm.deploy(Score.class);
var score = sm.mustDeploy(Score.class);
var nonNull = new byte[]{(byte)0};

// null -> null
Expand Down
2 changes: 1 addition & 1 deletion javaee/exec/test/java/foundation/icon/ee/KVDBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void run() {

@Test
void testExampleScore() {
var score = sm.deploy(Score.class);
var score = sm.mustDeploy(Score.class);
score.invoke("run");
}
}
8 changes: 4 additions & 4 deletions javaee/exec/test/java/foundation/icon/ee/ObjectHashTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package foundation.icon.ee;

import foundation.icon.ee.test.Contract;
import foundation.icon.ee.test.ContractAddress;
import foundation.icon.ee.test.SimpleTest;
import foundation.icon.ee.types.Status;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -98,13 +98,13 @@ public void call(String method) {
}
}

private Contract score;
private ContractAddress score;

@BeforeEach
public void setUp() {
super.setUp();
score = sm.deploy(A.class);
var score2 = sm.deploy(B.class, score.getAddress());
score = sm.mustDeploy(A.class);
var score2 = sm.mustDeploy(B.class, score.getAddress());
score.invoke("setNext", score2.getAddress());
}

Expand Down
2 changes: 1 addition & 1 deletion javaee/exec/test/java/foundation/icon/ee/QueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public int setVarDB() {

@Test
void testSetDB() {
var score = sm.deploy(Score.class);
var score = sm.mustDeploy(Score.class);
score.query("setDictDB");
score.query("setBranchDB");
score.query("setArrayDB");
Expand Down
10 changes: 5 additions & 5 deletions javaee/exec/test/java/foundation/icon/ee/ReadOnlyTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package foundation.icon.ee;

import foundation.icon.ee.test.Contract;
import foundation.icon.ee.test.ContractAddress;
import foundation.icon.ee.test.SimpleTest;
import foundation.icon.ee.test.TransactionException;
import foundation.icon.ee.types.Status;
Expand Down Expand Up @@ -91,14 +91,14 @@ public int createTempObject() {
}
}

private Contract score;
private ContractAddress score;
private TransactionException e;

@Nested
class Direct {
@BeforeEach
void setUp() {
score = sm.deploy(Score.class);
score = sm.mustDeploy(Score.class);
}

@Test
Expand Down Expand Up @@ -140,8 +140,8 @@ void creatingTempObjectSucceeds() {
class Indirect {
@BeforeEach
void setUp() {
var real = sm.deploy(Score.class);
score = sm.deploy(ProxyScore.class, real.getAddress());
var real = sm.mustDeploy(Score.class);
score = sm.mustDeploy(ProxyScore.class, real.getAddress());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion javaee/exec/test/java/foundation/icon/ee/ReenterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void reenter() {

@Test
public void test() {
var score = sm.deploy(Score.class);
var score = sm.mustDeploy(Score.class);
score.invoke("reenter");
}
}
10 changes: 5 additions & 5 deletions javaee/exec/test/java/foundation/icon/ee/SampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SampleTest extends GoldenTest {
@Test
public void testSample() {
var owner = sm.getOrigin();
var app = sm.deploy(SampleToken.class, "MySampleToken", "MST", 18, 1000);
var app = sm.mustDeploy(SampleToken.class, "MySampleToken", "MST", 18, 1000);
app.invoke("balanceOf", owner);
var addr1 = sm.newExternalAddress();
app.invoke("transfer", addr1, new BigInteger("1000000000000000000"), "Hello".getBytes(StandardCharsets.UTF_8));
Expand All @@ -29,7 +29,7 @@ public void testSample() {
app.invoke("balanceOf", addr1);
app.invoke("balanceOf", owner);
app.invoke("totalSupply");
var app2 = sm.deploy(CollectionTest.class);
var app2 = sm.mustDeploy(CollectionTest.class);
app2.invoke("getInt");
app2.invoke("totalSupply2", app.getAddress());
app2.invoke("balanceOf2", app.getAddress(), owner);
Expand All @@ -38,7 +38,7 @@ public void testSample() {
@Test
public void testInherited() {
var owner = sm.getOrigin();
var app = sm.deploy(new Class<?>[]{IRC2BasicToken.class, IRC2Basic.class, IRC2.class}, "MySampleToken", "MST", 18, 1000);
var app = sm.mustDeploy(new Class<?>[]{IRC2BasicToken.class, IRC2Basic.class, IRC2.class}, "MySampleToken", "MST", 18, 1000);
app.invoke("balanceOf", owner);
var addr1 = sm.newExternalAddress();
app.invoke("transfer", addr1, new BigInteger("1000000000000000000"), "Hello".getBytes(StandardCharsets.UTF_8));
Expand All @@ -47,7 +47,7 @@ public void testInherited() {
app.invoke("balanceOf", addr1);
app.invoke("balanceOf", owner);
app.invoke("totalSupply");
var app2 = sm.deploy(CollectionTest.class);
var app2 = sm.mustDeploy(CollectionTest.class);
app2.invoke("getInt");
app2.invoke("totalSupply2", app.getAddress());
app2.invoke("balanceOf2", app.getAddress(), owner);
Expand All @@ -56,7 +56,7 @@ public void testInherited() {
@Test
public void testIRC3() {
var owner = sm.getOrigin();
var app = sm.deploy(new Class<?>[]{IRC3BasicToken.class, IRC3Basic.class, IRC3.class,
var app = sm.mustDeploy(new Class<?>[]{IRC3BasicToken.class, IRC3Basic.class, IRC3.class,
EnumerableIntMap.class, Arrays.class}, "MyNFT", "NFT");
app.invoke("balanceOf", owner);
app.invoke("totalSupply");
Expand Down
Loading

0 comments on commit 3eae825

Please sign in to comment.