@Test
public void transferUsingNonceTest() throws Exception{
String testPrivateKey = "0x07f2066d045c19f72479cf3079a8161244bb3a9d0899a3487b6ec00c13596360";
AbstractKeyring senderKeyring = TokenUtils.createFromPrivateKey(testPrivateKey);
AbstractKeyring feePayerKeyring = keyStoreTools.getFeePayerKeyring(true);
Caver caver = caverProvider.get();
TestTokenUtils TestTokenUtils = new TestTokenUtils(caver, TestTokenContractAddress, feePayerKeyring);
TestTokenUtils.getTestToken().setSender(senderKeyring);
String toWalletAddress = "0x980e41f0a74f1c3d749b8ec54d9e3de3279e1feb";
String amount = caver.utils.convertToPeb("1", Utils.KlayUnit.KLAY);
BigInteger nonce = caver.rpc.klay.getTransactionCount(senderKeyring.getAddress(), DefaultBlockParameterName.LATEST).send().getValue();
nonce.add(BigInteger.valueOf(5));
TransactionReceipt.TransactionReceiptData receiptData = TestTokenUtils.transfer(senderKeyring, toWalletAddress, new BigInteger(amount), nonce);
log.info("=============== receiptData : {}", objectToString(receiptData));
}
@Test
public void transferUsingNonceSleppTest() throws Exception{
String testPrivateKey = "0x07f2066d045c19f72479cf3079a8161244bb3a9d0899a3487b6ec00c13596360";
AbstractKeyring senderKeyring = TokenUtils.createFromPrivateKey(testPrivateKey);
AbstractKeyring feePayerKeyring = keyStoreTools.getFeePayerKeyring(true);
Caver caver = caverProvider.get();
TestTokenUtils TestTokenUtils = new TestTokenUtils(caver, TestTokenContractAddress, feePayerKeyring);
TestTokenUtils.getTestToken().setSender(senderKeyring);
String toWalletAddress = "0x980e41f0a74f1c3d749b8ec54d9e3de3279e1feb";
String amount = caver.utils.convertToPeb("1", Utils.KlayUnit.KLAY);
BigInteger nonce = caver.rpc.klay.getTransactionCount(senderKeyring.getAddress(), DefaultBlockParameterName.LATEST).send().getValue();
Thread.sleep(10000); // 10초 대기
TransactionReceipt.TransactionReceiptData receiptData = TestTokenUtils.transfer(senderKeyring, toWalletAddress, new BigInteger(amount), nonce);
log.info("=============== receiptData : {}", objectToString(receiptData));
}
jUnit으로 테스트하고 있는데 "transferUsingNonceSleppTest"을 먼저 실행하고 10초 sleep을 줬을 때 "transferUsingNonceTest"을 실행하였습니다.
transferUsingNonceTest은 성공하였고 transferUsingNonceSleppTest은 실패했는데 그때 오류 메시지는 "invalid fee payer: invalid account key"로 확인했습니다.
이 오류 문구가 어떤 상황에서 실패한건지 문의드립니다.