From fbbfd38d6c4c4b56f12ca6899294905860d06862 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Sat, 9 Nov 2024 06:57:37 +0100 Subject: [PATCH] Use http subscriptions instead of websocket for tests --- tests/contracts/testClock.nim | 2 +- tests/contracts/testMarket.nim | 28 +++++++++++----------------- tests/ethertest.nim | 7 ++++++- tests/tools/cirdl/testcirdl.nim | 2 +- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/tests/contracts/testClock.nim b/tests/contracts/testClock.nim index 40f7aed0..abc47496 100644 --- a/tests/contracts/testClock.nim +++ b/tests/contracts/testClock.nim @@ -30,7 +30,7 @@ ethersuite "On-Chain Clock": let waiting = clock.waitUntil(future) discard await ethProvider.send("evm_setNextBlockTimestamp", @[%future]) discard await ethProvider.send("evm_mine") - check await waiting.withTimeout(chronos.milliseconds(100)) + check await waiting.withTimeout(chronos.milliseconds(500)) test "can wait until a certain time is reached by the wall-clock": let future = clock.now() + 1 # seconds diff --git a/tests/contracts/testMarket.nim b/tests/contracts/testMarket.nim index a836628c..996fe893 100644 --- a/tests/contracts/testMarket.nim +++ b/tests/contracts/testMarket.nim @@ -114,8 +114,7 @@ ethersuite "On-Chain Market": receivedAsks.add(ask) let subscription = await market.subscribeRequests(onRequest) await market.requestStorage(request) - check receivedIds == @[request.id] - check receivedAsks == @[request.ask] + check eventually receivedIds == @[request.id] and receivedAsks == @[request.ask] await subscription.unsubscribe() test "supports filling of slots": @@ -181,8 +180,7 @@ ethersuite "On-Chain Market": let subscription = await market.subscribeSlotFilled(onSlotFilled) await market.reserveSlot(request.id, slotIndex) await market.fillSlot(request.id, slotIndex, proof, request.ask.collateral) - check receivedIds == @[request.id] - check receivedSlotIndices == @[slotIndex] + check eventually receivedIds == @[request.id] and receivedSlotIndices == @[slotIndex] await subscription.unsubscribe() test "subscribes only to a certain slot": @@ -194,10 +192,9 @@ ethersuite "On-Chain Market": let subscription = await market.subscribeSlotFilled(request.id, slotIndex, onSlotFilled) await market.reserveSlot(request.id, otherSlot) await market.fillSlot(request.id, otherSlot, proof, request.ask.collateral) - check receivedSlotIndices.len == 0 await market.reserveSlot(request.id, slotIndex) await market.fillSlot(request.id, slotIndex, proof, request.ask.collateral) - check receivedSlotIndices == @[slotIndex] + check eventually receivedSlotIndices == @[slotIndex] await subscription.unsubscribe() test "supports slot freed subscriptions": @@ -211,8 +208,7 @@ ethersuite "On-Chain Market": receivedIdxs.add(idx) let subscription = await market.subscribeSlotFreed(onSlotFreed) await market.freeSlot(slotId(request.id, slotIndex)) - check receivedRequestIds == @[request.id] - check receivedIdxs == @[slotIndex] + check eventually receivedRequestIds == @[request.id] and receivedIdxs == @[slotIndex] await subscription.unsubscribe() test "supports slot reservations full subscriptions": @@ -235,8 +231,7 @@ ethersuite "On-Chain Market": switchAccount(account3) await market.reserveSlot(request.id, slotIndex) - check receivedRequestIds == @[request.id] - check receivedIdxs == @[slotIndex] + check eventually receivedRequestIds == @[request.id] and receivedIdxs == @[slotIndex] await subscription.unsubscribe() test "support fulfillment subscriptions": @@ -248,7 +243,7 @@ ethersuite "On-Chain Market": for slotIndex in 0..