Skip to content

Commit

Permalink
test: submit batch signs (ethereum-optimism#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesterli authored Jun 24, 2024
1 parent 53a3d0c commit 5fa88e5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions itest/opstackl2/op_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/babylonchain/babylon/testutil/datagen"
"github.com/babylonchain/finality-provider/types"
sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -99,4 +100,38 @@ func TestOpSubmitFinalitySignature(t *testing.T) {
)
require.NoError(t, err)
t.Logf("Submit finality signature to op finality contract %s", submitRes.TxHash)

// mock more blocks
blocks := []*types.BlockInfo{}
var fpSigs []*secp256k1.ModNScalar
for i := 2; i <= 4; i++ {
block := &types.BlockInfo{
Height: uint64(i),
Hash: datagen.GenRandomByteArray(r, 32),
}
blocks = append(blocks, block)
// fp sign
fpSig, err := fpList[0].SignFinalitySig(block)
require.NoError(t, err)
fpSigs = append(fpSigs, fpSig.ToModNScalar())
}

// proofs
var proofs [][]byte
for i := 1; i <= 3; i++ {
proof, err := pubRandListInfo.ProofList[i].ToProto().Marshal()
require.NoError(t, err)
proofs = append(proofs, proof)
}

// submit batch finality signatures to smart contract
batchSubmitRes, err := ctm.OpL2ConsumerCtrl.SubmitBatchFinalitySigs(
msgPub.FpBtcPk.MustToBTCPK(),
blocks,
pubRandListInfo.PubRandList[1:4],
proofs,
fpSigs,
)
require.NoError(t, err)
t.Logf("Submit batch finality signatures to op finality contract %s", batchSubmitRes.TxHash)
}

0 comments on commit 5fa88e5

Please sign in to comment.