Skip to content

Commit

Permalink
fragile tests fix (#238)
Browse files Browse the repository at this point in the history
* fragile tests fix

* more fragile test fixes
  • Loading branch information
ClaytonNorthey92 authored Aug 29, 2024
1 parent f4b877f commit abce2ac
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions e2e/e2e_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,15 @@ func TestNewL2Keystone(t *testing.T) {
t.Fatal(err)
}

// there is a chance we get notifications from the L2KeystonesInsert
// call above, if they haven't been broadcast yet. ignore those.
if v.Header.Command == bfgapi.CmdL2KeystonesNotification {
err = wsjson.Read(ctx, c, &v)
if err != nil {
t.Fatal(err)
}
}

if v.Header.Command != bssapi.CmdL2KeystoneResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}
Expand Down Expand Up @@ -1341,6 +1350,14 @@ func TestBitcoinInfo(t *testing.T) {
}
bitcoinInfoResponse := v.(*bfgapi.BitcoinInfoResponse)

// there is a chance we get notifications from the L2KeystonesInsert
// call above, if they haven't been broadcast yet. ignore those.
if command == bfgapi.CmdL2KeystonesNotification {
err = wsjson.Read(ctx, c, &v)
if err != nil {
t.Fatal(err)
}
}
if command != bfgapi.CmdBitcoinInfoResponse {
t.Fatalf("unexpected command: %s", command)
}
Expand Down Expand Up @@ -1526,6 +1543,15 @@ func TestBitcoinBroadcast(t *testing.T) {
t.Fatal(err)
}

// there is a chance we get notifications from the L2KeystonesInsert
// call above, if they haven't been broadcast yet. ignore those.
if command == bfgapi.CmdL2KeystonesNotification {
command, _, _, err = bfgapi.Read(ctx, bws.conn)
if err != nil {
t.Fatal(err)
}
}

if command != bfgapi.CmdBitcoinBroadcastResponse {
t.Fatalf("received wrong command %s", command)
}
Expand Down Expand Up @@ -2361,6 +2387,15 @@ func TestGetMostRecentL2BtcFinalitiesBSS(t *testing.T) {
t.Fatal(err)
}

// there is a chance we get notifications from the L2KeystonesInsert
// call above, if they haven't been broadcast yet. ignore those.
if v.Header.Command == bfgapi.CmdL2KeystonesNotification {
err = wsjson.Read(ctx, c, &v)
if err != nil {
t.Fatal(err)
}
}

if v.Header.Command != bssapi.CmdBTCFinalityByRecentKeystonesResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}
Expand Down Expand Up @@ -2567,6 +2602,15 @@ func TestGetFinalitiesByL2KeystoneBSSLowerServerHeight(t *testing.T) {
t.Fatal(err)
}

// there is a chance we get notifications from the L2KeystonesInsert
// call above, if they haven't been broadcast yet. ignore those.
if v.Header.Command == bfgapi.CmdL2KeystonesNotification {
err = wsjson.Read(ctx, c, &v)
if err != nil {
t.Fatal(err)
}
}

if v.Header.Command != bssapi.CmdBTCFinalityByKeystonesResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}
Expand Down Expand Up @@ -2645,6 +2689,15 @@ func TestGetMostRecentL2BtcFinalitiesBFG(t *testing.T) {
t.Fatal(err)
}

// there is a chance we get notifications from the L2KeystonesInsert
// call above, if they haven't been broadcast yet. ignore those.
if v.Header.Command == bfgapi.CmdL2KeystonesNotification {
err = wsjson.Read(ctx, c, &v)
if err != nil {
t.Fatal(err)
}
}

if v.Header.Command != bfgapi.CmdBTCFinalityByRecentKeystonesResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}
Expand Down

0 comments on commit abce2ac

Please sign in to comment.