Skip to content

Commit 19e3369

Browse files
Hyunsik Jeongkseo
Hyunsik Jeong
authored andcommittedSep 7, 2018
Check connected after trying to connect
1 parent 5848a18 commit 19e3369

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed
 

‎test/src/helper/spawn.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ export default class CodeChain {
128128
if (!this.process) {
129129
return Promise.reject(Error("process isn't available"));
130130
}
131-
return this.sdk.rpc.network.connect("127.0.0.1", peer.port);
131+
await this.sdk.rpc.network.connect("127.0.0.1", peer.port);
132+
while (await this.sdk.rpc.network.isConnected("127.0.0.1", peer.port) === false) {
133+
wait(250);
134+
}
132135
}
133136

134137
public async disconnect(peer: CodeChain) {

‎test/src/integration/discovery.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ describe("2 nodes", () => {
3030

3131
test("should be able to connect", async () => {
3232
await nodeA.connect(nodeB);
33-
await wait(250);
34-
expect(await nodeA.sdk.rpc.network.isConnected("127.0.0.1", nodeB.port)).toBe(true);
3533
});
3634

3735
afterEach(async () => {

‎test/src/integration/sync.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ describe("2 nodes", () => {
3737

3838
describe("A-B connected", () => {
3939
beforeEach(async () => {
40-
await nodeA.sdk.rpc.network.connect("127.0.0.1", nodeB.port);
41-
await wait(250);
40+
await nodeA.connect(nodeB);
4241
});
4342

4443
test("It should be synced when nodeA created a block", async () => {
45-
expect(await nodeA.sdk.rpc.network.isConnected("127.0.0.1", nodeB.port)).toBe(true);
4644
const parcel = await nodeA.sendSignedParcel({ awaitInvoice: true });
4745
await nodeB.waitBlockNumberSync(nodeA);
4846
expect(await nodeB.getBestBlockHash()).toEqual(parcel.blockHash);

0 commit comments

Comments
 (0)
Please sign in to comment.