diff --git a/.circleci/config.yml b/.circleci/config.yml index c7fc39ea..e4b187f9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -180,6 +180,8 @@ workflows: <<: *test_steps name: publish_rc - publish_android: + requires: + - publish_rc <<: *stage_rc <<: *test_steps name: publish_android_rc @@ -195,6 +197,8 @@ workflows: <<: *test_steps name: publish_prod - publish_android: + requires: + - publish_prod <<: *stage_prod <<: *test_steps name: publish_android_prod diff --git a/src/test/java/xyz/groundx/caver_ext_kas/kas/kip17/KIP17Test.java b/src/test/java/xyz/groundx/caver_ext_kas/kas/kip17/KIP17Test.java index c50a9fd2..f95ee4ea 100644 --- a/src/test/java/xyz/groundx/caver_ext_kas/kas/kip17/KIP17Test.java +++ b/src/test/java/xyz/groundx/caver_ext_kas/kas/kip17/KIP17Test.java @@ -20,6 +20,7 @@ import com.klaytn.caver.transaction.response.PollingTransactionReceiptProcessor; import com.klaytn.caver.transaction.response.TransactionReceiptProcessor; import com.squareup.okhttp.Call; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -80,14 +81,14 @@ public static void init() throws Exception { caver.kas.kip17.getApiClient().setDebugging(true); prepareKIP17Contract(); - - } + @Test - public void deploy() throws ApiException { + public void deploy() throws ApiException, InterruptedException { Kip17TransactionStatusResponse response = caver.kas.kip17.deploy("KIP17", "KCT17", "kk-" + new Date().getTime()); assertNotNull(response); + Thread.sleep(5000); } @Test @@ -119,6 +120,8 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) fail(); } else { assertNotNull(future.get()); + Thread.sleep(5000); + } } @@ -225,14 +228,15 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) } @Test - public void mint() throws ApiException { + public void mint() throws ApiException, InterruptedException { String to = account; String id = Numeric.toHexStringWithPrefix(BigInteger.valueOf(new Date().getTime())); String uri = "https://test.com"; Kip17TransactionStatusResponse response = caver.kas.kip17.mint(testContractAlias, to, id, uri); - assertNotNull(response); + + Thread.sleep(5000); } @Test @@ -268,6 +272,7 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) fail(); } else { assertNotNull(future.get()); + Thread.sleep(5000); } } @@ -372,13 +377,14 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) } @Test - public void transfer() throws ApiException, IOException, TransactionException { + public void transfer() throws ApiException, IOException, TransactionException, InterruptedException { BigInteger tokenId = BigInteger.valueOf(new Date().getTime()); mintToken(testContractAlias, account, tokenId); String to = caver.kas.wallet.createAccount().getAddress(); Kip17TransactionStatusResponse response = caver.kas.kip17.transfer(testContractAlias, account, account, to, tokenId); assertNotNull(response); + Thread.sleep(5000); } @Test @@ -415,16 +421,18 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) fail(); } else { assertNotNull(future.get()); + Thread.sleep(5000); } } @Test - public void burn() throws ApiException, IOException, TransactionException { + public void burn() throws ApiException, IOException, TransactionException, InterruptedException { BigInteger id = BigInteger.valueOf(new Date().getTime()); mintToken(testContractAlias, account, id); Kip17TransactionStatusResponse burnResponse = caver.kas.kip17.burn(testContractAlias, account, id); assertNotNull(burnResponse); + Thread.sleep(5000); } @Test @@ -460,16 +468,19 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) fail(); } else { assertNotNull(future.get()); + Thread.sleep(5000); } } @Test - public void approve() throws ApiException { + public void approve() throws ApiException, InterruptedException { String from = account; String to = caver.kas.wallet.createAccount().getAddress(); Kip17TokenListResponse res = caver.kas.kip17.getTokenList(testContractAlias); Kip17TransactionStatusResponse response = caver.kas.kip17.approve(testContractAlias, from, to, res.getItems().get(0).getTokenId()); + assertNotNull(response); + Thread.sleep(5000); } @Test @@ -506,16 +517,18 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) fail(); } else { assertNotNull(completableFuture.get()); + Thread.sleep(5000); } } @Test - public void approveAll() throws ApiException, IOException, TransactionException { + public void approveAll() throws ApiException, InterruptedException { String from = caver.kas.wallet.createAccount().getAddress(); String to = caver.kas.wallet.createAccount().getAddress(); Kip17TransactionStatusResponse response = caver.kas.kip17.approveAll(testContractAlias, from, to, true); assertNotNull(response); + Thread.sleep(5000); } @Test @@ -551,6 +564,7 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) fail(); } else { assertNotNull(future.get()); + Thread.sleep(5000); } } diff --git a/src/test/java/xyz/groundx/caver_ext_kas/kas/wallet/WalletAPITest.java b/src/test/java/xyz/groundx/caver_ext_kas/kas/wallet/WalletAPITest.java index bfa794fa..0b69dbe5 100644 --- a/src/test/java/xyz/groundx/caver_ext_kas/kas/wallet/WalletAPITest.java +++ b/src/test/java/xyz/groundx/caver_ext_kas/kas/wallet/WalletAPITest.java @@ -22,15 +22,14 @@ import com.klaytn.caver.transaction.type.FeeDelegatedAccountUpdate; import com.klaytn.caver.wallet.keyring.KeyringFactory; import com.klaytn.caver.wallet.keyring.SingleKeyring; -import org.junit.Ignore; +import org.junit.*; +import org.junit.rules.ExpectedException; import xyz.groundx.caver_ext_kas.Config; import com.klaytn.caver.abi.ABI; import com.klaytn.caver.kct.kip7.KIP7; import com.klaytn.caver.kct.kip7.KIP7ConstantData; import com.klaytn.caver.utils.Utils; import com.squareup.okhttp.Call; -import org.junit.BeforeClass; -import org.junit.Test; import org.web3j.protocol.exceptions.TransactionException; import xyz.groundx.caver_ext_kas.CaverExtKAS; import xyz.groundx.caver_ext_kas.kas.wallet.accountkey.*; @@ -49,6 +48,9 @@ import static org.junit.Assert.*; public class WalletAPITest { + @Rule + public ExpectedException expectedException = ExpectedException.none(); + public static CaverExtKAS caver; static String userFeePayer; @@ -121,8 +123,9 @@ public static Account createMultiSig() { request.setWeightedKeys(multiSigKeys); MultisigAccount account = caver.kas.wallet.updateToMultiSigAccount(baseAccount.getAddress(), request); + Thread.sleep(3000); return baseAccount; - } catch (ApiException | TransactionException | IOException e) { + } catch (ApiException | TransactionException | IOException | InterruptedException e) { e.printStackTrace(); } @@ -232,6 +235,11 @@ private static KeyTypeRoleBased createRoleBasedKeyType(Account account) throws A return roleBasedUpdateKeyType; } + @Before + public void beforeSleep() throws InterruptedException { + Thread.sleep(5000); + } + @Test public void makeUncompressedFormat_LegacyKeyType() { KeyTypeLegacy type = new KeyTypeLegacy(); @@ -781,7 +789,19 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) } @Test - public void requestLegacyTransaction() { + public void requestLegacyTransaction() throws ApiException { + LegacyTransactionRequest request = new LegacyTransactionRequest(); + request.setFrom(baseAccount); + request.setTo(toAccount); + request.setValue("0x1"); + request.setSubmit(true); + + TransactionResult result = caver.kas.wallet.requestLegacyTransaction(request); + assertNotNull(result); + } + + @Test + public void requestLegacyTransactionAsync() { CompletableFuture future = new CompletableFuture<>(); try { @@ -1136,61 +1156,59 @@ public void requestAccountUpdateFailAsync() { } @Test - public void requestAccountUpdateToAccountKeyLegacy() { - try { - Account account = makeAccount(); - Config.sendValue(account.getAddress()); - KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); + public void requestAccountUpdateToAccountKeyLegacy() throws TransactionException, IOException, ApiException, InterruptedException { + expectedException.expect(ApiException.class); - AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest(); - request.setFrom(account.getAddress()); - request.setAccountKey(updateKeyType); - request.setSubmit(true); + Account account = makeAccount(); + Config.sendValue(account.getAddress()); + KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); - TransactionResult result = caver.kas.wallet.requestAccountUpdate(request); - assertNotNull(result); + AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest(); + request.setFrom(account.getAddress()); + request.setAccountKey(updateKeyType); + request.setSubmit(true); - AccountUpdateTransactionRequest requestLegacy = new AccountUpdateTransactionRequest(); - requestLegacy.setFrom(account.getAddress()); - requestLegacy.setAccountKey(new KeyTypeLegacy()); - requestLegacy.setSubmit(true); + TransactionResult result = caver.kas.wallet.requestAccountUpdate(request); + assertNotNull(result); + + Thread.sleep(5000); + + AccountUpdateTransactionRequest requestLegacy = new AccountUpdateTransactionRequest(); + requestLegacy.setFrom(account.getAddress()); + requestLegacy.setAccountKey(new KeyTypeLegacy()); + requestLegacy.setSubmit(true); + + TransactionResult result1 = caver.kas.wallet.requestAccountUpdate(requestLegacy); - TransactionResult result1 = caver.kas.wallet.requestAccountUpdate(requestLegacy); - assertNotNull(result1); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } } @Test - public void requestAccountUpdateToAccountKeyLegacyAsync() { + public void requestAccountUpdateToAccountKeyLegacyAsync() throws ApiException, ExecutionException, InterruptedException, TransactionException, IOException { + expectedException.expect(ExecutionException.class); + BasicTxCallBack callBack = new BasicTxCallBack(); - try { - Account account = makeAccount(); - Config.sendValue(account.getAddress()); - KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); + Account account = makeAccount(); + Config.sendValue(account.getAddress()); + KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); - AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest(); - request.setFrom(account.getAddress()); - request.setAccountKey(updateKeyType); - request.setSubmit(true); + AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest(); + request.setFrom(account.getAddress()); + request.setAccountKey(updateKeyType); + request.setSubmit(true); - TransactionResult result = caver.kas.wallet.requestAccountUpdate(request); - assertNotNull(result); + TransactionResult result = caver.kas.wallet.requestAccountUpdate(request); + assertNotNull(result); - AccountUpdateTransactionRequest requestLegacy = new AccountUpdateTransactionRequest(); - requestLegacy.setFrom(account.getAddress()); - requestLegacy.setAccountKey(new KeyTypeLegacy()); - requestLegacy.setSubmit(true); + Thread.sleep(5000); - caver.kas.wallet.requestAccountUpdateAsync(requestLegacy, callBack); - callBack.checkResponse(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } + AccountUpdateTransactionRequest requestLegacy = new AccountUpdateTransactionRequest(); + requestLegacy.setFrom(account.getAddress()); + requestLegacy.setAccountKey(new KeyTypeLegacy()); + requestLegacy.setSubmit(true); + + caver.kas.wallet.requestAccountUpdateAsync(requestLegacy, callBack); + callBack.checkResponse(); } @Test @@ -1559,61 +1577,59 @@ public void requestRawTransactionPaidByGlobalFeePayerAsync() { } @Test - public void requestFDAccountUpdatePaidByGlobalFeePayerToLegacyType() { - try { - Account account = makeAccount(); + public void requestFDAccountUpdatePaidByGlobalFeePayerToLegacyType() throws ApiException, InterruptedException { + expectedException.expect(ApiException.class); - KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); + Account account = makeAccount(); - FDAccountUpdateTransactionRequest request = new FDAccountUpdateTransactionRequest(); - request.setFrom(account.getAddress()); - request.setAccountKey(updateKeyType); - request.setSubmit(true); + KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); - FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(request); - assertNotNull(result); + FDAccountUpdateTransactionRequest request = new FDAccountUpdateTransactionRequest(); + request.setFrom(account.getAddress()); + request.setAccountKey(updateKeyType); + request.setSubmit(true); - FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); - requestLegacy.setFrom(account.getAddress()); - requestLegacy.setAccountKey(new KeyTypeLegacy()); - requestLegacy.setSubmit(true); + FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(request); + assertNotNull(result); - FDTransactionResult result1 = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(requestLegacy); - assertNotNull(result1); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } + Thread.sleep(5000); + + FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); + requestLegacy.setFrom(account.getAddress()); + requestLegacy.setAccountKey(new KeyTypeLegacy()); + requestLegacy.setSubmit(true); + + FDTransactionResult result1 = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(requestLegacy); + assertNotNull(result1); } @Test - public void requestFDAccountUpdatePaidByGlobalFeePayerToLegacyTypeAsync() { + public void requestFDAccountUpdatePaidByGlobalFeePayerToLegacyTypeAsync() throws ApiException, InterruptedException, ExecutionException { + expectedException.expect(ExecutionException.class); + FDTxCallBack callBack = new FDTxCallBack(); - try { - Account account = makeAccount(); + Account account = makeAccount(); - KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); + KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); - FDAccountUpdateTransactionRequest request = new FDAccountUpdateTransactionRequest(); - request.setFrom(account.getAddress()); - request.setAccountKey(updateKeyType); - request.setSubmit(true); + FDAccountUpdateTransactionRequest request = new FDAccountUpdateTransactionRequest(); + request.setFrom(account.getAddress()); + request.setAccountKey(updateKeyType); + request.setSubmit(true); - FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(request); - assertNotNull(result); + FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(request); + assertNotNull(result); - FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); - requestLegacy.setFrom(account.getAddress()); - requestLegacy.setAccountKey(new KeyTypeLegacy()); - requestLegacy.setSubmit(true); + Thread.sleep(5000); - caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayerAsync(requestLegacy, callBack); - callBack.checkResponse(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } + FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); + requestLegacy.setFrom(account.getAddress()); + requestLegacy.setAccountKey(new KeyTypeLegacy()); + requestLegacy.setSubmit(true); + + caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayerAsync(requestLegacy, callBack); + callBack.checkResponse(); } @Test @@ -1989,7 +2005,6 @@ public void requestRawTransactionPaidByUser() { e.printStackTrace(); fail(); } - } @Test @@ -2020,65 +2035,63 @@ public void requestRawTransactionPaidByUserAsync() { } @Test - public void requestFDAccountUpdatePaidByUserToLegacyType() { - try { - Account account = makeAccount(); + public void requestFDAccountUpdatePaidByUserToLegacyType() throws ApiException, InterruptedException { + expectedException.expect(ApiException.class); - KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); + Account account = makeAccount(); - FDUserAccountUpdateTransactionRequest request = new FDUserAccountUpdateTransactionRequest(); - request.setFrom(account.getAddress()); - request.setAccountKey(updateKeyType); - request.setFeePayer(userFeePayer); - request.setSubmit(true); + KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); - FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByUser(request); - assertNotNull(result); + FDUserAccountUpdateTransactionRequest request = new FDUserAccountUpdateTransactionRequest(); + request.setFrom(account.getAddress()); + request.setAccountKey(updateKeyType); + request.setFeePayer(userFeePayer); + request.setSubmit(true); - FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); - requestLegacy.setFrom(account.getAddress()); - requestLegacy.setAccountKey(new KeyTypeLegacy()); - request.setFeePayer(userFeePayer); - requestLegacy.setSubmit(true); + FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByUser(request); + assertNotNull(result); - FDTransactionResult result1 = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(requestLegacy); - assertNotNull(result1); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } + Thread.sleep(5000); + + FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); + requestLegacy.setFrom(account.getAddress()); + requestLegacy.setAccountKey(new KeyTypeLegacy()); + request.setFeePayer(userFeePayer); + requestLegacy.setSubmit(true); + + FDTransactionResult result1 = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(requestLegacy); + assertNotNull(result1); } @Test - public void requestFDAccountUpdatePaidByUserToLegacyTypeAsync() { + public void requestFDAccountUpdatePaidByUserToLegacyTypeAsync() throws ApiException, ExecutionException, InterruptedException { + expectedException.expect(ExecutionException.class); + FDTxCallBack callBack = new FDTxCallBack(); - try { - Account account = makeAccount(); + Account account = makeAccount(); - KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); + KeyTypePublic updateKeyType = new KeyTypePublic(account.getPublicKey()); - FDUserAccountUpdateTransactionRequest request = new FDUserAccountUpdateTransactionRequest(); - request.setFrom(account.getAddress()); - request.setAccountKey(updateKeyType); - request.setFeePayer(userFeePayer); - request.setSubmit(true); + FDUserAccountUpdateTransactionRequest request = new FDUserAccountUpdateTransactionRequest(); + request.setFrom(account.getAddress()); + request.setAccountKey(updateKeyType); + request.setFeePayer(userFeePayer); + request.setSubmit(true); - FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByUser(request); - assertNotNull(result); + FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByUser(request); + assertNotNull(result); - FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); - requestLegacy.setFrom(account.getAddress()); - requestLegacy.setAccountKey(new KeyTypeLegacy()); - request.setFeePayer(userFeePayer); - requestLegacy.setSubmit(true); + Thread.sleep(5000); - caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayerAsync(requestLegacy, callBack); - callBack.checkResponse(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } + FDAccountUpdateTransactionRequest requestLegacy = new FDAccountUpdateTransactionRequest(); + requestLegacy.setFrom(account.getAddress()); + requestLegacy.setAccountKey(new KeyTypeLegacy()); + request.setFeePayer(userFeePayer); + requestLegacy.setSubmit(true); + + caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayerAsync(requestLegacy, callBack); + callBack.checkResponse(); } @Test @@ -2272,6 +2285,7 @@ public void getMultiSigTransactions() { try { if(!hasMultiSigTx(multiSigAddress)) { sendValueTransferForMultiSig(multiSigAddress, toAccount); + Thread.sleep(3000); } MultisigTransactions transactions = caver.kas.wallet.getMultiSigTransactionList(multiSigAccount.getAddress()); @@ -2290,6 +2304,7 @@ public void getMultiSigTransactionsAsync() { try { if(!hasMultiSigTx(multiSigAddress)) { sendValueTransferForMultiSig(multiSigAddress, toAccount); + Thread.sleep(3000); } caver.kas.wallet.getMultiSigTransactionListAsync(multiSigAccount.getAddress(), new ApiCallback() { @@ -2331,12 +2346,13 @@ public void signMultiSigTransaction() { try { if(!hasMultiSigTx(multiSigAddress)) { sendValueTransferForMultiSig(multiSigAddress, toAccount); + Thread.sleep(3000); } MultisigTransactions transactions = caver.kas.wallet.getMultiSigTransactionList(multiSigAddress); MultisigTransactionStatus status = caver.kas.wallet.signMultiSigTransaction(transactions.getItems().get(0).getMultiSigKeys().get(1).getAddress(), transactions.getItems().get(0).getTransactionId()); assertNotNull(status); - } catch (ApiException e) { + } catch (ApiException | InterruptedException e) { e.printStackTrace(); fail(); } @@ -2349,6 +2365,7 @@ public void signMultiSigTransactionAsync() { try { if(!hasMultiSigTx(multiSigAddress)) { sendValueTransferForMultiSig(multiSigAddress, toAccount); + Thread.sleep(3000); } MultisigTransactions transactions = caver.kas.wallet.getMultiSigTransactionList(multiSigAddress); @@ -2390,6 +2407,7 @@ public void signTransaction() { try { if(!hasMultiSigTx(multiSigAddress)) { sendValueTransferForMultiSig(multiSigAddress, toAccount); + Thread.sleep(3000); } MultisigTransactions transactions = caver.kas.wallet.getMultiSigTransactionList(multiSigAddress); Signature signature = caver.kas.wallet.signTransaction(transactions.getItems().get(0).getMultiSigKeys().get(2).getAddress(), transactions.getItems().get(0).getTransactionId()); @@ -2407,6 +2425,7 @@ public void signTransactionAsync() { try { if(!hasMultiSigTx(multiSigAddress)) { sendValueTransferForMultiSig(multiSigAddress, toAccount); + Thread.sleep(3000); } MultisigTransactions transactions = caver.kas.wallet.getMultiSigTransactionList(multiSigAddress); caver.kas.wallet.signTransactionAsync(transactions.getItems().get(0).getMultiSigKeys().get(2).getAddress(), transactions.getItems().get(0).getTransactionId(), new ApiCallback() { @@ -2473,6 +2492,7 @@ public void appendSignaturesAsync() { try { if(!hasMultiSigTx(multiSigAddress)) { sendValueTransferForMultiSig(multiSigAddress, toAccount); + Thread.sleep(3000); }