Skip to content

Commit

Permalink
watchtower/wtwire/wtwire_test: test failcodes and Data field
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed Jul 11, 2018
1 parent 6f38478 commit 4f640ad
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions watchtower/wtwire/wtwire_test.go
Expand Up @@ -78,14 +78,16 @@ func TestWatchtowerWireProtocol(t *testing.T) {
},
wtwire.MsgSessionInitReply: func(v []reflect.Value, r *rand.Rand) {
req := &wtwire.SessionInitReply{
Code: uint16(r.Int31()),
Code: wtwire.SessionInitCode(r.Int31()),
}

rewardAddrLen := rand.Int31n(96)
dataLen := rand.Int31n(
wtwire.MaxSessionInitReplyDataLength,
)

req.RewardPkScript = make([]byte, rewardAddrLen)
if _, err := r.Read(req.RewardPkScript); err != nil {
t.Fatalf("unable to generate reward pk script: %v",
req.Data = make([]byte, dataLen)
if _, err := r.Read(req.Data); err != nil {
t.Fatalf("unable to generate data: %v",
err)
return
}
Expand All @@ -95,6 +97,7 @@ func TestWatchtowerWireProtocol(t *testing.T) {
wtwire.MsgStateUpdate: func(v []reflect.Value, r *rand.Rand) {
req := &wtwire.StateUpdate{
SeqNum: uint16(r.Int31()),
IsComplete: uint8(r.Int31()),
LastApplied: uint16(r.Int31()),
}

Expand All @@ -117,7 +120,7 @@ func TestWatchtowerWireProtocol(t *testing.T) {
},
wtwire.MsgStateUpdateReply: func(v []reflect.Value, r *rand.Rand) {
req := &wtwire.StateUpdateReply{
Code: uint16(r.Int31()),
Code: wtwire.StateUpdateCode(r.Int31()),
LastApplied: uint16(r.Int31()),
}

Expand Down

0 comments on commit 4f640ad

Please sign in to comment.