执行器检查逻辑修改
This commit is contained in:
1 parent
f3f4a306e5
commit
f55f4c2961
14 files changed
+298
-26
No files matched your search
@@ -36,6 +36,7 @@ public class ChainCommandExecutorTest {
|
||||
private int signedCount;
|
||||
private int broadcasts;
|
||||
private boolean acceptBroadcast;
|
||||
private boolean failEstimateWithLinkageError;
|
||||
private byte[] firstTransaction;
|
||||
|
||||
@Before
|
||||
@@ -70,6 +71,7 @@ public class ChainCommandExecutorTest {
|
||||
};
|
||||
WalletOperationEstimateService estimates = new WalletOperationEstimateService(networks) {
|
||||
@Override public WalletResourceEstimateVo estimate(String type, WalletAddressPlus wallet, WalletOperationRequest request) {
|
||||
if (failEstimateWithLinkageError) throw new NoSuchMethodError("simulated protobuf conflict");
|
||||
WalletResourceEstimateVo estimate = new WalletResourceEstimateVo();
|
||||
estimate.setEstimatedBurnTrx(BigDecimal.ZERO);
|
||||
return estimate;
|
||||
@@ -108,6 +110,7 @@ public class ChainCommandExecutorTest {
|
||||
assertEquals(0, signedCount);
|
||||
assertEquals(0, broadcasts);
|
||||
assertEquals("FAILED", store.get(id).get("status"));
|
||||
assertTrue(String.valueOf(store.get(id).get("error_message")).contains("阶段=VALIDATE_EXPIRY"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,6 +144,18 @@ public class ChainCommandExecutorTest {
|
||||
assertEquals(0, broadcasts);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void linkageErrorBeforeSigningMarksExecutionFailed() {
|
||||
failEstimateWithLinkageError = true;
|
||||
executor.execute(executionId, "test-only-password");
|
||||
Map<String, Object> result = store.get(executionId);
|
||||
assertEquals("FAILED", result.get("status"));
|
||||
assertTrue(String.valueOf(result.get("error_message")).contains("阶段=ESTIMATE_RESOURCES"));
|
||||
assertTrue(String.valueOf(result.get("error_message")).contains("异常类型=NoSuchMethodError"));
|
||||
assertEquals(0, signedCount);
|
||||
assertEquals(0, broadcasts);
|
||||
}
|
||||
|
||||
private ChainCommand command() {
|
||||
ChainCommand command = new ChainCommand();
|
||||
command.businessKey = "WALLET:test";
|
||||
|
||||
@@ -69,6 +69,23 @@ public class ChainExecutionStoreTest {
|
||||
assertEquals("BROADCASTED", store.get(id).get("status"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartRequeuesOnlyUnsignedRemoteRunningExecution() {
|
||||
String unsignedRemote = (String) store.create(command("PAYOUT:unsigned"), true).get("execution_id");
|
||||
String password = (String) store.create(command("PAYOUT:password"), false).get("execution_id");
|
||||
String signedRemote = (String) store.create(command("PAYOUT:signed"), true).get("execution_id");
|
||||
assertTrue(store.claim(unsignedRemote));
|
||||
assertTrue(store.claim(password));
|
||||
assertTrue(store.claim(signedRemote));
|
||||
store.signed(signedRemote, "known-hash", new byte[] {1});
|
||||
|
||||
assertEquals(1, store.requeueUnsignedRemoteExecutions());
|
||||
assertEquals("QUEUED", store.get(unsignedRemote).get("status"));
|
||||
assertEquals("RUNNING", store.get(password).get("status"));
|
||||
assertEquals("SIGNED", store.get(signedRemote).get("status"));
|
||||
assertArrayEquals(new byte[] {1}, (byte[]) store.get(signedRemote).get("signed_transaction"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureBeforeSigningCanBeArchivedWithoutLosingAudit() {
|
||||
String id = (String) store.create(command(), false).get("execution_id");
|
||||
@@ -105,8 +122,12 @@ public class ChainExecutionStoreTest {
|
||||
}
|
||||
|
||||
private ChainCommand command() {
|
||||
return command("PAYOUT:123");
|
||||
}
|
||||
|
||||
private ChainCommand command(String businessKey) {
|
||||
ChainCommand command = new ChainCommand();
|
||||
command.businessKey = "PAYOUT:123";
|
||||
command.businessKey = businessKey;
|
||||
command.operatorId = 1L;
|
||||
command.type = "usdt";
|
||||
command.operation = new WalletOperationRequest();
|
||||
|
||||
Reference in new issue
Block a user