test: contract function selector errors
package com.hedera.hashgraph.sdk;
import org.bouncycastle.util.encoders.Hex;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class ContractFunctionSelectorTest {
@Test
+ @DisplayName("Can add all types")
void selector() {
var signature = new ContractFunctionSelector("testFunction")
.addAddress()
@@ -39,4 +43,15 @@ public class ContractFunctionSelectorTest {
assertEquals("4438e4ce", Hex.toHexString(signature));
}
+
+ @Test
+ @DisplayName("Throws in adding after finished")
+ void selectorError() {
+ var signature = new ContractFunctionSelector("testFunction")
+ .addAddress();
+ signature.finish();
+
+ assertThrows(IllegalStateException.class, signature::addStringArray);
+ assertDoesNotThrow(signature::finish);
+ }
}
