@@ -75,7 +75,7 @@ describe('Channel other', () => {
75
75
const [ initiatorBalanceBeforeClose , responderBalanceBeforeClose ] = await getBalances ( ) ;
76
76
const closeSoloTx = await aeSdk . buildTx ( {
77
77
tag : Tag . ChannelCloseSoloTx ,
78
- channelId : await initiatorCh . id ( ) ,
78
+ channelId : initiatorCh . id ( ) ,
79
79
fromId : initiator . address ,
80
80
poi,
81
81
payload : signedTx ,
@@ -85,7 +85,7 @@ describe('Channel other', () => {
85
85
86
86
const settleTx = await aeSdk . buildTx ( {
87
87
tag : Tag . ChannelSettleTx ,
88
- channelId : await initiatorCh . id ( ) ,
88
+ channelId : initiatorCh . id ( ) ,
89
89
fromId : initiator . address ,
90
90
initiatorAmountFinal : balances [ initiator . address ] ,
91
91
responderAmountFinal : balances [ responder . address ] ,
@@ -164,36 +164,33 @@ describe('Channel other', () => {
164
164
. should . be . equal ( true ) ;
165
165
} ) . timeout ( timeoutBlock ) ;
166
166
167
- // https://github.com/aeternity/protocol/blob/d634e7a3f3110657900759b183d0734e61e5803a/node/api/channels_api_usage.md#reestablish
168
- it ( 'can reconnect' , async ( ) => {
169
- expect ( await initiatorCh . round ( ) ) . to . be . equal ( 1 ) ;
170
- const result = await initiatorCh . update (
171
- initiator . address ,
172
- responder . address ,
173
- 100 ,
174
- initiatorSign ,
175
- ) ;
176
- expect ( result . accepted ) . to . equal ( true ) ;
177
- const channelId = await initiatorCh . id ( ) ;
167
+ it ( 'can reconnect a channel without leave' , async ( ) => {
168
+ expect ( initiatorCh . round ( ) ) . to . be . equal ( 1 ) ;
169
+ await initiatorCh . update ( initiator . address , responder . address , 100 , initiatorSign ) ;
170
+ expect ( initiatorCh . round ( ) ) . to . be . equal ( 2 ) ;
171
+ const channelId = initiatorCh . id ( ) ;
178
172
const fsmId = initiatorCh . fsmId ( ) ;
179
173
initiatorCh . disconnect ( ) ;
174
+ await waitForChannel ( initiatorCh , [ 'disconnected' ] ) ;
180
175
const ch = await Channel . initialize ( {
181
176
...sharedParams ,
182
177
...initiatorParams ,
183
178
existingChannelId : channelId ,
184
179
existingFsmId : fsmId ,
185
180
} ) ;
186
- await waitForChannel ( ch ) ;
181
+ await waitForChannel ( ch , [ 'open' ] ) ;
187
182
expect ( ch . fsmId ( ) ) . to . be . equal ( fsmId ) ;
188
- expect ( await ch . round ( ) ) . to . be . equal ( 2 ) ;
183
+ expect ( ch . round ( ) ) . to . be . equal ( 2 ) ;
189
184
const state = await ch . state ( ) ;
190
- ch . disconnect ( ) ;
191
185
assertNotNull ( state . signedTx ) ;
192
186
expect ( state . signedTx . encodedTx . tag ) . to . be . equal ( Tag . ChannelOffChainTx ) ;
187
+ await ch . update ( initiator . address , responder . address , 100 , initiatorSign ) ;
188
+ expect ( ch . round ( ) ) . to . be . equal ( 3 ) ;
189
+ ch . disconnect ( ) ;
193
190
} ) ;
194
191
195
192
it ( 'can post backchannel update' , async ( ) => {
196
- expect ( await responderCh . round ( ) ) . to . be . equal ( 1 ) ;
193
+ expect ( responderCh . round ( ) ) . to . be . equal ( 1 ) ;
197
194
initiatorCh . disconnect ( ) ;
198
195
const { accepted } = await responderCh . update (
199
196
initiator . address ,
@@ -202,7 +199,7 @@ describe('Channel other', () => {
202
199
responderSign ,
203
200
) ;
204
201
expect ( accepted ) . to . equal ( false ) ;
205
- expect ( await responderCh . round ( ) ) . to . be . equal ( 1 ) ;
202
+ expect ( responderCh . round ( ) ) . to . be . equal ( 1 ) ;
206
203
const result = await responderCh . update (
207
204
initiator . address ,
208
205
responder . address ,
@@ -212,7 +209,7 @@ describe('Channel other', () => {
212
209
) ,
213
210
) ;
214
211
result . accepted . should . equal ( true ) ;
215
- expect ( await responderCh . round ( ) ) . to . be . equal ( 2 ) ;
212
+ expect ( responderCh . round ( ) ) . to . be . equal ( 2 ) ;
216
213
expect ( result . signedTx ) . to . be . a ( 'string' ) ;
217
214
} ) ;
218
215
} ) ;
0 commit comments