File tree 3 files changed +5
-6
lines changed
3 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,10 @@ export default class CodeChain {
128
128
if ( ! this . process ) {
129
129
return Promise . reject ( Error ( "process isn't available" ) ) ;
130
130
}
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
+ }
132
135
}
133
136
134
137
public async disconnect ( peer : CodeChain ) {
Original file line number Diff line number Diff line change @@ -30,8 +30,6 @@ describe("2 nodes", () => {
30
30
31
31
test ( "should be able to connect" , async ( ) => {
32
32
await nodeA . connect ( nodeB ) ;
33
- await wait ( 250 ) ;
34
- expect ( await nodeA . sdk . rpc . network . isConnected ( "127.0.0.1" , nodeB . port ) ) . toBe ( true ) ;
35
33
} ) ;
36
34
37
35
afterEach ( async ( ) => {
Original file line number Diff line number Diff line change @@ -37,12 +37,10 @@ describe("2 nodes", () => {
37
37
38
38
describe ( "A-B connected" , ( ) => {
39
39
beforeEach ( async ( ) => {
40
- await nodeA . sdk . rpc . network . connect ( "127.0.0.1" , nodeB . port ) ;
41
- await wait ( 250 ) ;
40
+ await nodeA . connect ( nodeB ) ;
42
41
} ) ;
43
42
44
43
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 ) ;
46
44
const parcel = await nodeA . sendSignedParcel ( { awaitInvoice : true } ) ;
47
45
await nodeB . waitBlockNumberSync ( nodeA ) ;
48
46
expect ( await nodeB . getBestBlockHash ( ) ) . toEqual ( parcel . blockHash ) ;
You can’t perform that action at this time.
0 commit comments