Skip to content

Commit

Permalink
test update
Browse files Browse the repository at this point in the history
  • Loading branch information
joroshiba committed Oct 16, 2024
1 parent f84a877 commit 4176faf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
30 changes: 15 additions & 15 deletions grpc/execution/server_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package execution

import (
astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1alpha2"
astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1"
primitivev1 "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1"
sequencerblockv1alpha1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1alpha1"
sequencerblockv1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1"
"bytes"
"context"
"crypto/sha256"
Expand Down Expand Up @@ -269,7 +269,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlock(t *testing.T) {
// create the txs to send
// create 5 txs
txs := []*types.Transaction{}
marshalledTxs := []*sequencerblockv1alpha1.RollupData{}
marshalledTxs := []*sequencerblockv1.RollupData{}
for i := 0; i < 5; i++ {
unsignedTx := types.NewTransaction(uint64(i), testToAddress, big.NewInt(1), params.TxGas, big.NewInt(params.InitialBaseFee*2), nil)
tx, err := types.SignTx(unsignedTx, types.LatestSigner(ethservice.BlockChain().Config()), testKey)
Expand All @@ -278,8 +278,8 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlock(t *testing.T) {

marshalledTx, err := tx.MarshalBinary()
require.Nil(t, err, "Failed to marshal tx")
marshalledTxs = append(marshalledTxs, &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{SequencedData: marshalledTx},
marshalledTxs = append(marshalledTxs, &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{SequencedData: marshalledTx},
})
}

Expand All @@ -295,7 +295,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlock(t *testing.T) {

chainDestinationAddress := crypto.PubkeyToAddress(chainDestinationAddressPrivKey.PublicKey)

depositTx := &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
depositTx := &sequencerblockv1.RollupData{Value: &sequencerblockv1.RollupData_Deposit{Deposit: &sequencerblockv1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
Expand Down Expand Up @@ -361,7 +361,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitment(t *testi

// create 5 txs
txs := []*types.Transaction{}
marshalledTxs := []*sequencerblockv1alpha1.RollupData{}
marshalledTxs := []*sequencerblockv1.RollupData{}
for i := 0; i < 5; i++ {
unsignedTx := types.NewTransaction(uint64(i), testToAddress, big.NewInt(1), params.TxGas, big.NewInt(params.InitialBaseFee*2), nil)
tx, err := types.SignTx(unsignedTx, types.LatestSigner(ethservice.BlockChain().Config()), testKey)
Expand All @@ -370,8 +370,8 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitment(t *testi

marshalledTx, err := tx.MarshalBinary()
require.Nil(t, err, "Failed to marshal tx")
marshalledTxs = append(marshalledTxs, &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{SequencedData: marshalledTx},
marshalledTxs = append(marshalledTxs, &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{SequencedData: marshalledTx},
})
}

Expand All @@ -392,7 +392,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitment(t *testi

chainDestinationAddressBalanceBefore := stateDb.GetBalance(chainDestinationAddress)

depositTx := &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
depositTx := &sequencerblockv1.RollupData{Value: &sequencerblockv1.RollupData_Deposit{Deposit: &sequencerblockv1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitmentWithInval

// create 5 txs
txs := []*types.Transaction{}
marshalledTxs := []*sequencerblockv1alpha1.RollupData{}
marshalledTxs := []*sequencerblockv1.RollupData{}
for i := 0; i < 5; i++ {
unsignedTx := types.NewTransaction(latestNonce+uint64(i), testToAddress, big.NewInt(1), params.TxGas, big.NewInt(params.InitialBaseFee*2), nil)
tx, err := types.SignTx(unsignedTx, types.LatestSigner(ethservice.BlockChain().Config()), testKey)
Expand All @@ -515,8 +515,8 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitmentWithInval

marshalledTx, err := tx.MarshalBinary()
require.Nil(t, err, "Failed to marshal tx")
marshalledTxs = append(marshalledTxs, &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{SequencedData: marshalledTx},
marshalledTxs = append(marshalledTxs, &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{SequencedData: marshalledTx},
})
}

Expand All @@ -528,8 +528,8 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitmentWithInval

marshalledTx, err := tx.MarshalBinary()
require.Nil(t, err, "Failed to marshal tx")
marshalledTxs = append(marshalledTxs, &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{SequencedData: marshalledTx},
marshalledTxs = append(marshalledTxs, &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{SequencedData: marshalledTx},
})

errors := ethservice.TxPool().Add(txs, true, false)
Expand Down
28 changes: 14 additions & 14 deletions grpc/execution/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

primitivev1 "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1"
sequencerblockv1alpha1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1alpha1"
sequencerblockv1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1"
"github.com/btcsuite/btcd/btcutil/bech32"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -86,40 +86,40 @@ func TestSequenceTxValidation(t *testing.T) {

tests := []struct {
description string
sequencerTx *sequencerblockv1alpha1.RollupData
sequencerTx *sequencerblockv1.RollupData
// just check if error contains the string since error contains other details
wantErr string
}{
{
description: "unmarshallable sequencer tx",
sequencerTx: &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{
sequencerTx: &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{
SequencedData: []byte("unmarshallable tx"),
},
},
wantErr: "failed to unmarshal sequenced data into transaction",
},
{
description: "blob type sequence tx",
sequencerTx: &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{
sequencerTx: &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{
SequencedData: blobTx,
},
},
wantErr: "blob tx not allowed in sequenced data",
},
{
description: "deposit type sequence tx",
sequencerTx: &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{
sequencerTx: &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{
SequencedData: depositTx,
},
},
wantErr: "deposit tx not allowed in sequenced data",
},
{
description: "deposit tx with an unknown bridge address",
sequencerTx: &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
sequencerTx: &sequencerblockv1.RollupData{Value: &sequencerblockv1.RollupData_Deposit{Deposit: &sequencerblockv1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: generateBech32MAddress(),
},
Expand All @@ -136,7 +136,7 @@ func TestSequenceTxValidation(t *testing.T) {
},
{
description: "deposit tx with a disallowed asset id",
sequencerTx: &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
sequencerTx: &sequencerblockv1.RollupData{Value: &sequencerblockv1.RollupData_Deposit{Deposit: &sequencerblockv1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
Expand All @@ -153,7 +153,7 @@ func TestSequenceTxValidation(t *testing.T) {
},
{
description: "deposit tx with a height and asset below the bridge start height",
sequencerTx: &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
sequencerTx: &sequencerblockv1.RollupData{Value: &sequencerblockv1.RollupData_Deposit{Deposit: &sequencerblockv1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: invalidHeightBridgeAddressBech32m,
},
Expand All @@ -170,7 +170,7 @@ func TestSequenceTxValidation(t *testing.T) {
},
{
description: "valid deposit tx",
sequencerTx: &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
sequencerTx: &sequencerblockv1.RollupData{Value: &sequencerblockv1.RollupData_Deposit{Deposit: &sequencerblockv1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
Expand All @@ -187,8 +187,8 @@ func TestSequenceTxValidation(t *testing.T) {
},
{
description: "valid sequencer tx",
sequencerTx: &sequencerblockv1alpha1.RollupData{
Value: &sequencerblockv1alpha1.RollupData_SequencedData{SequencedData: validMarshalledTx},
sequencerTx: &sequencerblockv1.RollupData{
Value: &sequencerblockv1.RollupData_SequencedData{SequencedData: validMarshalledTx},
},
wantErr: "",
},
Expand Down

0 comments on commit 4176faf

Please sign in to comment.