Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make less likely to spend coinbase #3

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestFullNetwork(t *testing.T) {
"-rpcuser=user",
"-rpcpassword=password",
"generatetoaddress",
"300", // need to generate a lot for greater chance to not spend coinbase
"5000", // need to generate a lot for greater chance to not spend coinbase
btcAddress.EncodeAddress(),
})
if err != nil {
Expand Down Expand Up @@ -213,11 +213,10 @@ func TestFullNetwork(t *testing.T) {
}()

go func() {
// create a new block every second, then view pop payouts and finalities

firstL2Keystone := hemi.L2KeystoneAbbreviate(l2Keystone).Serialize()

for {
l2Keystone.L2BlockNumber++
l2Keystone.L1BlockNumber++

l2KeystoneRequest := bssapi.L2KeystoneRequest{
L2Keystone: l2Keystone,
}
Expand All @@ -228,6 +227,14 @@ func TestFullNetwork(t *testing.T) {
return
}

// give time for the L2 Keystone to propogate to bitcoin tx mempool
select {
case <-time.After(10 * time.Second):
case <-ctx.Done():
panic(ctx.Err())
}

// generate a new btc block, this should include the l2 keystone
err = runBitcoinCommand(ctx,
t,
bitcoindContainer,
Expand All @@ -246,21 +253,17 @@ func TestFullNetwork(t *testing.T) {
return
}

l2Keystone.L1BlockNumber++
l2Keystone.L2BlockNumber++

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
// give time for bfg to see the new block
select {
case <-time.After(10 * time.Second):
case <-ctx.Done():
panic(ctx.Err())
}

err = bssapi.Write(ctx, bws.conn, "someotheridz", bssapi.BTCFinalityByRecentKeystonesRequest{
NumRecentKeystones: 100,
// ensure the l2 keystone is in the chain
ks := hemi.L2KeystoneAbbreviate(l2Keystone).Serialize()
err = bssapi.Write(ctx, bws.conn, "someotherid", bssapi.PopPayoutsRequest{
L2BlockForPayout: ks[:],
})
if err != nil {
t.Logf("error: %s", err)
Expand Down