PolicyContract extends SmartContract { public List<ScriptHash> getBlockedAccounts() throws IOException { StackItem arrayItem = callInvokeFunction(GET_BLOCKED_ACCOUNTS) .getInvocationResult().getStack().get(0); if (!arrayItem.getType().equals(StackItemType.ARRAY)) { throw new UnexpectedReturnTypeException(arrayItem.getType(), StackItemType.ARRAY); } return arrayItem.asArray().getValue() .stream().map(ac -> ScriptHash.fromAddress(ac.asByteString().getAsAddress())) .collect(Collectors.toList()); } PolicyContract(Neow3j neow); Integer getMaxTransactionsPerBlock(); Integer getMaxBlockSize(); BigInteger getMaxBlockSystemFee(); Integer getFeePerByte(); List<ScriptHash> getBlockedAccounts(); TransactionBuilder setMaxBlockSize(Integer maxBlockSize); TransactionBuilder setMaxTransactionsPerBlock(Integer maxTxPerBlock); TransactionBuilder setMaxBlockSystemFee(BigInteger maxBlockSystemFee); TransactionBuilder setFeePerByte(Integer fee); TransactionBuilder blockAccount(ScriptHash accountToBlock); TransactionBuilder unblockAccount(ScriptHash accountToUnblock); static final ScriptHash SCRIPT_HASH; }
@Test public void getBlockedAccounts() throws IOException { setUpWireMockForInvokeFunction("getBlockedAccounts", "policy_getBlockedAccounts.json"); PolicyContract policyContract = new PolicyContract(this.neow3j); List<ScriptHash> blockedAccounts = policyContract.getBlockedAccounts(); assertNotNull(blockedAccounts); assertThat(blockedAccounts.size(), is(2)); assertThat(blockedAccounts, contains( ScriptHash.fromAddress("Aa1rZbE1k8fXTwzaxxsPRtJYPwhDQjWRFZ"), ScriptHash.fromAddress("ATpVyfpFwE2SzNGSvXDNrtRyfVLajhn7yN"))); }
@Test public void getBlockedAccounts_emptyList() throws IOException { setUpWireMockForInvokeFunction("getBlockedAccounts", "policy_getBlockedAccounts_empty.json"); PolicyContract policyContract = new PolicyContract(neow3j); assertNotNull(policyContract.getBlockedAccounts()); assertThat(policyContract.getBlockedAccounts().size(), is(0)); }