Skip to content

Commit

Permalink
tests, tests, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikebbers committed Jul 15, 2024
1 parent 5023862 commit b9400a5
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void testCallFunctionWithInvalidParam() throws Exception {
}

@Test
void testCallFunctionResult() throws Exception {
void testCallFunctionWithResult() throws Exception {
//given
final Path path = Path.of(ContractServiceTest.class.getResource("/uint_getter_setter_contract.bin").getPath());
final ContractId contract = smartContractClient.createContract(path);
Expand All @@ -173,4 +173,32 @@ void testCallFunctionResult() throws Exception {
Assertions.assertEquals(BigInteger.valueOf(123), result.getInt256(0));
}

@Test
void testCallFunctionWithWrongResult() throws Exception {
//given
final Path path = Path.of(ContractServiceTest.class.getResource("/uint_getter_setter_contract.bin").getPath());
final ContractId contract = smartContractClient.createContract(path);
smartContractClient.callContractFunction(contract, "set", int256(123));

//when
final ContractCallResult result = smartContractClient.callContractFunction(contract, "get");

//then
Assertions.assertThrows(IllegalArgumentException.class, () -> result.getString(0));
}

@Test
void testCallFunctionWithWrongResultCount() throws Exception {
//given
final Path path = Path.of(ContractServiceTest.class.getResource("/uint_getter_setter_contract.bin").getPath());
final ContractId contract = smartContractClient.createContract(path);
smartContractClient.callContractFunction(contract, "set", int256(123));

//when
final ContractCallResult result = smartContractClient.callContractFunction(contract, "get");

//then
Assertions.assertThrows(IllegalArgumentException.class, () -> result.getString(1));
}

}

0 comments on commit b9400a5

Please sign in to comment.