@@ -68,6 +68,56 @@ func TestVirtualChannelsOptimistic(t *testing.T) {
68
68
assert .NoError (t , err , "Bob: invalid final balances" )
69
69
}
70
70
71
+ func TestVirtualChannelsDispute (t * testing.T ) {
72
+ ctx , cancel := context .WithTimeout (context .Background (), testDuration )
73
+ defer cancel ()
74
+
75
+ vct := setupVirtualChannelTest (t , ctx )
76
+ var err error
77
+ assert := assert .New (t )
78
+
79
+ // Alice registers and settles channel with Ingrid.
80
+ err = vct .registerAndSettle (ctx , vct .chAliceIngrid )
81
+ assert .NoError (err , "alice-ingrid: register and settle" )
82
+
83
+ // Ingrid registers and settles channel with Alice.
84
+ err = vct .registerAndSettle (ctx , vct .chIngridAlice )
85
+ assert .NoError (err , "ingrid-alice: register and settle" )
86
+
87
+ // Bob registers and settles channel with Ingrid.
88
+ err = vct .registerAndSettle (ctx , vct .chBobIngrid )
89
+ assert .NoError (err , "bob-ingrid: register and settle" )
90
+
91
+ // Ingrid registers and settles channel with Bob.
92
+ err = vct .registerAndSettle (ctx , vct .chIngridBob )
93
+ assert .NoError (err , "ingrid-bob: register and settle" )
94
+ }
95
+
96
+ func TestVirtualChannelsDisputeHubFirst (t * testing.T ) {
97
+ ctx , cancel := context .WithTimeout (context .Background (), testDuration )
98
+ defer cancel ()
99
+
100
+ vct := setupVirtualChannelTest (t , ctx )
101
+ var err error
102
+ assert := assert .New (t )
103
+
104
+ // Ingrid registers and settles channel with Alice.
105
+ err = vct .registerAndSettle (ctx , vct .chIngridAlice )
106
+ assert .NoError (err , "ingrid-alice: register and settle" )
107
+
108
+ // Alice registers and settles channel with Ingrid.
109
+ err = vct .registerAndSettle (ctx , vct .chAliceIngrid )
110
+ assert .NoError (err , "alice-ingrid: register and settle" )
111
+
112
+ // Ingrid registers and settles channel with Bob.
113
+ err = vct .registerAndSettle (ctx , vct .chIngridBob )
114
+ assert .NoError (err , "ingrid-bob: register and settle" )
115
+
116
+ // Bob registers and settles channel with Ingrid.
117
+ err = vct .registerAndSettle (ctx , vct .chBobIngrid )
118
+ assert .NoError (err , "bob-ingrid: register and settle" )
119
+ }
120
+
71
121
type virtualChannelTest struct {
72
122
chAliceIngrid * client.Channel
73
123
chIngridAlice * client.Channel
@@ -228,3 +278,13 @@ func setupVirtualChannelTest(t *testing.T, ctx context.Context) (vct virtualChan
228
278
require .NoError (err , "updating virtual channel" )
229
279
return
230
280
}
281
+
282
+ func (vct virtualChannelTest ) registerAndSettle (ctx context.Context , ch * client.Channel ) (err error ) {
283
+ err = ch .Register (ctx )
284
+ if err != nil {
285
+ return
286
+ }
287
+
288
+ err = ch .Settle (ctx , false )
289
+ return
290
+ }
0 commit comments