NeoToken extends Nep5Token { public List<ECPublicKey> getValidators() throws IOException { return callFunctionReturningListOfPublicKeys(GET_VALIDATORS); } NeoToken(Neow3j neow); @Override String getName(); @Override String getSymbol(); @Override BigInteger getTotalSupply(); @Override int getDecimals(); BigInteger unclaimedGas(ScriptHash scriptHash, long blockHeight); TransactionBuilder registerCandidate(ECPublicKey candidateKey); TransactionBuilder unregisterCandidate(ECPublicKey candidateKey); List<ECPublicKey> getValidators(); List<ECPublicKey> getCommittee(); Map<ECPublicKey, Integer> getCandidates(); List<ECPublicKey> getNextBlockValidators(); TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators); final static int DECIMALS; final static String NAME; final static String SYMBOL; final static BigInteger TOTAL_SUPPLY; static final ScriptHash SCRIPT_HASH; static final String UNCLAIMED_GAS; static final String REGISTER_CANDIDATE; static final String UNREGISTER_CANDIDATE; static final String VOTE; static final String GET_CANDIDATES; static final String GET_VALIDATORS; static final String GET_COMMITTEE; static final String GET_NEXT_BLOCK_VALIDATORS; }
@Test public void getValidators() throws IOException { String responseBody = ContractTestHelper.loadFile( "/responses/invokefunction_getvalidators.json"); WireMock.stubFor(post(urlEqualTo("/")) .withRequestBody(new RegexPattern("" + ".*\"method\":\"invokefunction\"" + ".*\"params\":" + ".*\"de5f57d430d3dece511cf975a8d37848cb9e0525\"" + ".*\"getValidators\".*" )) .willReturn(aResponse() .withStatus(200) .withBody(responseBody))); List<ECPublicKey> result = new NeoToken(neow).getValidators(); String expKeyHex = "02c0b60c995bc092e866f15a37c176bb59b7ebacf069ba94c0ebf561cb8f956238"; System.out.println(Numeric.toBigInt(Numeric.hexStringToByteArray(expKeyHex))); ECPublicKey expKey = new ECPublicKey(Numeric.hexStringToByteArray(expKeyHex)); assertThat(result, contains(expKey)); }