Skip to content

Commit

Permalink
do not spend coinbase
Browse files Browse the repository at this point in the history
as of now, we don't retry mining keystones if they fail.  in e2e tests we only check that 1 keystone was mined, if this fails, then the test fails.  make this highly unlikely by doing two things:
* generating a lot of blocks, 300 to start, 100 every second
* don't check the same keystone for mining, check every keystone, this is an e2e test; if one was mined it passes

fixes #2
  • Loading branch information
ClaytonNorthey92 committed Feb 26, 2024
1 parent 7c778c0 commit 3179e66
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,15 @@ func TestFullNetwork(t *testing.T) {
go func() {
// create a new block every second, then view pop payouts and finalities

firstL2Keystone := hemi.L2KeystoneAbbreviate(l2Keystone).Serialize()
keystones := []hemi.L2Keystone{}

for {
l2KeystoneRequest := bssapi.L2KeystoneRequest{
L2Keystone: l2Keystone,
}

keystones = append(keystones, l2Keystone)

err = bssapi.Write(ctx, bws.conn, "someid", l2KeystoneRequest)
if err != nil {
t.Logf("error: %s", err)
Expand All @@ -237,7 +239,7 @@ func TestFullNetwork(t *testing.T) {
"-rpcuser=user",
"-rpcpassword=password",
"generatetoaddress",
"1",
"100", // generate a bunch so we're less likely to spend coinbase
btcAddress.EncodeAddress(),
},
)
Expand All @@ -251,20 +253,15 @@ func TestFullNetwork(t *testing.T) {

time.Sleep(1 * time.Second)

err = bssapi.Write(ctx, bws.conn, "someotherid", bssapi.PopPayoutsRequest{
L2BlockForPayout: firstL2Keystone[:],
})
if err != nil {
t.Logf("error: %s", err)
return
}

err = bssapi.Write(ctx, bws.conn, "someotheridz", bssapi.BTCFinalityByRecentKeystonesRequest{
NumRecentKeystones: 100,
})
if err != nil {
t.Logf("error: %s", err)
return
for _, keystone := range keystones {
ks := hemi.L2KeystoneAbbreviate(keystone).Serialize()
err = bssapi.Write(ctx, bws.conn, "someotherid", bssapi.PopPayoutsRequest{
L2BlockForPayout: ks[:],
})
if err != nil {
t.Logf("error: %s", err)
return
}
}
}
}()
Expand Down

0 comments on commit 3179e66

Please sign in to comment.