Skip to content

Commit

Permalink
added needed test waits since recent l2 keystones are updated async (h…
Browse files Browse the repository at this point in the history
…emilabs#233)

* added needed test waits since recent l2 keystones are updated async

* try 2 seconds

* fix spelling

* check for command
  • Loading branch information
ClaytonNorthey92 authored Aug 27, 2024
1 parent cdbbfbd commit 49f3de0
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions e2e/e2e_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ func TestBitcoinBroadcast(t *testing.T) {
}

// async now, in a rush, sleep should work
time.Sleep(5 * time.Second)
time.Sleep(2 * time.Second)

command, _, _, err := bfgapi.Read(ctx, bws.conn)
if err != nil {
Expand Down Expand Up @@ -2345,6 +2345,8 @@ func TestGetMostRecentL2BtcFinalitiesBSS(t *testing.T) {
NumRecentKeystones: 100,
}

time.Sleep(5 * time.Second)

err = bssapi.Write(ctx, bws.conn, "someid", finalityRequest)
if err != nil {
t.Fatal(err)
Expand All @@ -2360,6 +2362,8 @@ func TestGetMostRecentL2BtcFinalitiesBSS(t *testing.T) {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

time.Sleep(5 * time.Second)

recentFinalities, err := db.L2BTCFinalityMostRecent(ctx, 100)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -2424,7 +2428,7 @@ func TestGetFinalitiesByL2KeystoneBSS(t *testing.T) {
conn: protocol.NewWSConn(c),
}

time.Sleep(5 * time.Second)
time.Sleep(2 * time.Second)

// first and second btcBlocks
recentFinalities, err := db.L2BTCFinalityMostRecent(ctx, 100)
Expand Down Expand Up @@ -2519,7 +2523,7 @@ func TestGetFinalitiesByL2KeystoneBSSLowerServerHeight(t *testing.T) {
conn: protocol.NewWSConn(c),
}

time.Sleep(5 * time.Second)
time.Sleep(2 * time.Second)

// first and second btcBlocks
recentFinalities, err := db.L2BTCFinalityMostRecent(ctx, 100)
Expand Down Expand Up @@ -2612,7 +2616,7 @@ func TestGetMostRecentL2BtcFinalitiesBFG(t *testing.T) {
conn: protocol.NewWSConn(c),
}

time.Sleep(5 * time.Second)
time.Sleep(2 * time.Second)

finalityRequest := bfgapi.BTCFinalityByRecentKeystonesRequest{
NumRecentKeystones: 100,
Expand Down Expand Up @@ -2695,6 +2699,8 @@ func TestGetFinalitiesByL2KeystoneBFG(t *testing.T) {
conn: protocol.NewWSConn(c),
}

time.Sleep(5 * time.Second)

// first and second btcBlocks
recentFinalities, err := db.L2BTCFinalityMostRecent(ctx, 100)
if err != nil {
Expand Down Expand Up @@ -2725,6 +2731,15 @@ func TestGetFinalitiesByL2KeystoneBFG(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.CmdBTCFinalityByKeystonesResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}
Expand Down

0 comments on commit 49f3de0

Please sign in to comment.