loopout/test: refactor test
@@ -179,10 +179,16 @@ func testResume(t *testing.T, expired, preimageRevealed, expectSuccess bool) {
var receiverKey [33]byte
copy(receiverKey[:], receiverPubKey.SerializeCompressed())
- state := loopdb.StateInitiated
+ update := loopdb.LoopEvent{
+ SwapStateData: loopdb.SwapStateData{
+ State: loopdb.StateInitiated,
+ },
+ }
+
if preimageRevealed {
- state = loopdb.StatePreimageRevealed
+ update.State = loopdb.StatePreimageRevealed
}
+
pendingSwap := &loopdb.LoopOut{
Contract: &loopdb.LoopOutContract{
DestAddr: dest,
@@ -201,13 +207,7 @@ func testResume(t *testing.T, expired, preimageRevealed, expectSuccess bool) {
},
},
Loop: loopdb.Loop{
- Events: []*loopdb.LoopEvent{
- {
- SwapStateData: loopdb.SwapStateData{
- State: state,
- },
- },
- },
+ Events: []*loopdb.LoopEvent{&update},
Hash: hash,
},
}
