租赁模块-地址上链下单成功,节点在线,设置也都正确,钱包资源也充足,但是节点没有接收这个类型的订单,无法上链成功。问题修复
This commit is contained in:
1 parent
3ca5ff43ea
commit
547a04d12b
3 files changed
+131
-16
No files matched your search
@@ -41,6 +41,7 @@ public class RentalBusinessTest {
|
||||
private boolean receiverActivated;
|
||||
private boolean activationRpcFailed;
|
||||
private int activationChecks;
|
||||
private long supplierBalanceSun = 10000000L;
|
||||
private static final String ADDRESS = "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf";
|
||||
private static final String OWNER = "TR7NHqjeKQxGTCi8q8ZY4pL8otgjLj6t";
|
||||
private final ObjectMapper json = new ObjectMapper();
|
||||
@@ -654,7 +655,7 @@ public class RentalBusinessTest {
|
||||
new RentalChain(json) {
|
||||
@Override
|
||||
public com.fasterxml.jackson.databind.JsonNode call(String network, String path, Map<String, Object> body) {
|
||||
return json.valueToTree(map("balance", 10000000));
|
||||
return json.valueToTree(map("balance", supplierBalanceSun));
|
||||
}
|
||||
@Override
|
||||
public long relation(
|
||||
@@ -754,6 +755,73 @@ public class RentalBusinessTest {
|
||||
expectFailure(() -> tx.execute(status -> orders.create(app, 10, request)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onchainDispatchDoesNotRequireStakeSnapshotAndStillVerifiesTransfer() {
|
||||
store.update("node", node, map("transfer_enabled", 1));
|
||||
store.update("wallet", wallet, map("snapshot_block_height", null,
|
||||
"snapshot_at", null, "snapshot_expires_at", null,
|
||||
"energy_enabled", 0, "bandwidth_enabled", 0));
|
||||
long id = number(tx.execute(status -> orders.create(app, 10,
|
||||
onchainRequest("onchain-no-snapshot"))), "id");
|
||||
tasks.dispatch(id);
|
||||
tasks.dispatch(id);
|
||||
Map<String, Object> task = store.one("SELECT * FROM rent_task WHERE order_id=?", id);
|
||||
assertNotNull(task);
|
||||
assertEquals("TRANSFER_TRX", text(task, "task_type"));
|
||||
assertEquals(0L, number(task, "conversion_block_height"));
|
||||
assertEquals(1, store.rows("SELECT id FROM rent_task WHERE order_id=?", id).size());
|
||||
tasks.report(node, map("task_no", task.get("task_no"), "event_id", "no-snapshot-built",
|
||||
"state", "BUILT", "tx_id", String.join("", Collections.nCopies(64, "d"))));
|
||||
tasks.verify(number(task, "id"));
|
||||
assertEquals("SUCCESS", text(store.get("order", id, false), "status"));
|
||||
assertEquals("CHARGED", text(store.get("order", id, false), "fund_status"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onchainAcceptsExpiredSnapshotButResourceRentalStillWaits() {
|
||||
store.update("node", node, map("transfer_enabled", 1));
|
||||
store.update("wallet", wallet, map("snapshot_expires_at", after(-60)));
|
||||
long rentalId = number(create("resource-expired-snapshot"), "id");
|
||||
tasks.dispatch(rentalId);
|
||||
assertNull(store.one("SELECT id FROM rent_task WHERE order_id=?", rentalId));
|
||||
long transferId = number(tx.execute(status -> orders.create(app, 10,
|
||||
onchainRequest("onchain-expired-snapshot"))), "id");
|
||||
tasks.dispatch(transferId);
|
||||
assertNotNull(store.one("SELECT id FROM rent_task WHERE order_id=?", transferId));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onchainWithoutSnapshotStillRequiresVerifiedOnlineAuthorizedWalletAndBalance() {
|
||||
store.update("node", node, map("transfer_enabled", 1));
|
||||
store.update("wallet", wallet, map("snapshot_expires_at", null));
|
||||
long id = number(tx.execute(status -> orders.create(app, 10,
|
||||
onchainRequest("onchain-guards"))), "id");
|
||||
store.update("wallet", wallet, map("ownership_verified_at", null));
|
||||
tasks.dispatch(id);
|
||||
assertNull(store.one("SELECT id FROM rent_task WHERE order_id=?", id));
|
||||
store.update("wallet", wallet, map("ownership_verified_at", now(), "network", "MAINNET"));
|
||||
tasks.dispatch(id);
|
||||
assertNull(store.one("SELECT id FROM rent_task WHERE order_id=?", id));
|
||||
store.update("wallet", wallet, map("network", "NILE"));
|
||||
store.update("node", node, map("connection_status", "OFFLINE"));
|
||||
tasks.dispatch(id);
|
||||
assertNull(store.one("SELECT id FROM rent_task WHERE order_id=?", id));
|
||||
store.update("node", node, map("connection_status", "ONLINE", "heartbeat_expires_at", after(-60)));
|
||||
tasks.dispatch(id);
|
||||
assertNull(store.one("SELECT id FROM rent_task WHERE order_id=?", id));
|
||||
store.update("node", node, map("heartbeat_expires_at", after(300), "transfer_enabled", 0));
|
||||
tasks.dispatch(id);
|
||||
assertNull(store.one("SELECT id FROM rent_task WHERE order_id=?", id));
|
||||
store.update("node", node, map("transfer_enabled", 1));
|
||||
supplierBalanceSun = 3999999L;
|
||||
tasks.dispatch(id);
|
||||
assertNull(store.one("SELECT id FROM rent_task WHERE order_id=?", id));
|
||||
assertEquals("HELD", text(store.get("order", id, false), "fund_status"));
|
||||
supplierBalanceSun = 4000000L;
|
||||
tasks.dispatch(id);
|
||||
assertNotNull(store.one("SELECT id FROM rent_task WHERE order_id=?", id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onchainRequiresCapableNodeAndChargesOnlyAfterIndependentProof() {
|
||||
Map<String, Object> order = tx.execute(status -> orders.create(app, 10, onchainRequest("onchain-success")));
|
||||
|
||||
Reference in new issue
Block a user