Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

Commit 479ab9a

Browse files
Change test to assert we persist data between restarts
1 parent 197d206 commit 479ab9a

File tree

3 files changed

+42
-24
lines changed

3 files changed

+42
-24
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { createActors } from "../../../lib_sdk/create_actors";
2+
3+
setTimeout(function() {
4+
describe("cnd can be restarted", function() {
5+
this.timeout(60000);
6+
it("after the swap was accepted", async function() {
7+
const { alice, bob } = await createActors(
8+
"cnd_can_be_restarted.log"
9+
);
10+
11+
await alice.sendRequest();
12+
await bob.accept();
13+
14+
await alice.currentSwapIsAccepted();
15+
await bob.currentSwapIsAccepted();
16+
17+
await alice.restart();
18+
await bob.restart();
19+
20+
await alice.currentSwapIsAccepted();
21+
await bob.currentSwapIsAccepted();
22+
});
23+
});
24+
run();
25+
}, 0);

api_tests/e2e/rfc003/btc_eth/does_not_persist_data.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

api_tests/lib_sdk/actors/actor.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import "../../lib/setup_chai";
1010
import { Asset, AssetKind } from "../asset";
1111
import { CndInstance } from "../cnd_instance";
1212
import { Ledger, LedgerKind } from "../ledger";
13+
import { sleep } from "../utils";
1314
import { Wallets } from "../wallets";
1415
import { Actors } from "./index";
1516

@@ -186,12 +187,24 @@ export class Actor {
186187
await this.swap.redeem(Actor.defaultActionConfig);
187188
}
188189

189-
public async assertHasNoSwaps() {
190-
this.logger.debug("Checking if we have 0 swaps");
190+
public async currentSwapIsAccepted() {
191+
let swapEntity;
191192

192-
const swaps = await this.cnd.getSwaps();
193+
do {
194+
swapEntity = await this.swap.getEntity();
193195

194-
expect(swaps).to.have.length(0);
196+
await sleep(200);
197+
} while (
198+
swapEntity.properties.state.communication.status !== "ACCEPTED"
199+
);
200+
}
201+
202+
public async assertHasCurrentSwap() {
203+
this.logger.debug("Checking if we can fetch the current swap");
204+
205+
const response = await this.cnd.fetch(this.swap.self);
206+
207+
return response;
195208
}
196209

197210
public async assertSwapped() {

0 commit comments

Comments
 (0)