@@ -71,22 +71,15 @@ func TestHandshake(t *testing.T) {
71
71
err = protocolTester .TestExchanges (p2ptest.Exchange {
72
72
Label : "TestHandshake" ,
73
73
Triggers : []p2ptest.Trigger {
74
- {
75
- Code : 1 ,
76
- Msg : & EmitChequeMsg {
77
- Cheque : cheque ,
78
- },
79
- Peer : debitor .ID (),
80
- },
81
- },
82
- Expects : []p2ptest.Expect {
83
74
{
84
75
Code : 0 ,
85
76
Msg : & HandshakeMsg {
86
77
ContractAddress : swap .owner .Contract ,
87
78
},
88
79
Peer : creditor .ID (),
89
80
},
81
+ },
82
+ Expects : []p2ptest.Expect {
90
83
{
91
84
Code : 0 ,
92
85
Msg : & HandshakeMsg {
@@ -182,16 +175,11 @@ func TestEmitCheque(t *testing.T) {
182
175
if creditorSwap .balances [debitor .ID ()] != 0 {
183
176
t .Fatalf ("Expected debitor balance to have been reset to %d, but it is %d" , 0 , creditorSwap .balances [debitor .ID ()])
184
177
}
185
- /*
186
- TODO: This test actually fails now, because the two Swaps create independent backends,
187
- thus when handling the cheque, it will actually complain (check ERROR log output)
188
- with `error="no contract code at given address"`.
189
- Therefore, the `lastReceivedCheque` is not being saved, and this check would fail.
190
- So TODO is to find out how to address this (should be by having same backend when creating the Swap)
191
- if creditorSwap.loadLastReceivedCheque(debitor.ID()) != cheque {
192
- t.Fatalf("Expected exactly one cheque at creditor, but there are %d:", len(creditorSwap.cheques))
193
- }
194
- */
178
+ recvCheque := creditorSwap .loadLastReceivedCheque (debitor )
179
+ log .Debug ("expected cheque" , "cheque" , recvCheque )
180
+ if recvCheque != cheque {
181
+ t .Fatalf ("Expected exactly one cheque at creditor, but there are %d:" , len (creditorSwap .cheques ))
182
+ }
195
183
}
196
184
197
185
// TestTriggerPaymentThreshold is to test that the whole cheque protocol is triggered
0 commit comments