Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions adapters/consensus2p2p/consensus_p2p_adapters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/NethermindEth/juno/adapters/consensus2p2p/testutils"
"github.com/NethermindEth/juno/adapters/p2p2consensus"
transactiontestutils "github.com/NethermindEth/juno/adapters/testutils"
"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -44,7 +44,7 @@ func TestAdaptProposalCommitment(t *testing.T) {
func TestAdaptProposalTransaction(t *testing.T) {
consensusTransactions, p2pTransactions := transactiontestutils.GetTestTransactions(
t,
&utils.Mainnet,
&networks.Mainnet,
testutils.TransactionBuilder.GetTestDeclareTransaction,
testutils.TransactionBuilder.GetTestDeployAccountTransaction,
testutils.TransactionBuilder.GetTestInvokeTransaction,
Expand All @@ -58,7 +58,7 @@ func TestAdaptProposalTransaction(t *testing.T) {
require.Equal(t, p2pTransactions[i], convertedP2PTransaction)

convertedConsensusTransaction, err := p2p2consensus.AdaptTransaction(
t.Context(), compiler.NewUnsafe(), convertedP2PTransaction, &utils.Mainnet,
t.Context(), compiler.NewUnsafe(), convertedP2PTransaction, &networks.Mainnet,
)
require.NoError(t, err)

Expand All @@ -74,7 +74,7 @@ func TestAdaptProposalTransaction(t *testing.T) {
require.Equal(t, p2pTransactions, convertedP2PTransactions.Transactions)

convertedConsensusTransactions, err := p2p2consensus.AdaptProposalTransaction(
t.Context(), compiler.NewUnsafe(), &convertedP2PTransactions, &utils.Mainnet,
t.Context(), compiler.NewUnsafe(), &convertedP2PTransactions, &networks.Mainnet,
)
require.NoError(t, err)
for i := range consensusTransactions {
Expand Down
6 changes: 3 additions & 3 deletions adapters/mempool2p2p/mempool_p2p_adapters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"github.com/NethermindEth/juno/adapters/mempool2p2p/testutils"
"github.com/NethermindEth/juno/adapters/p2p2mempool"
transactiontestutils "github.com/NethermindEth/juno/adapters/testutils"
"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
"github.com/stretchr/testify/require"
)

func TestAdaptTransaction(t *testing.T) {
mempoolTransactions, p2pTransactions := transactiontestutils.GetTestTransactions(
t,
&utils.Sepolia,
&networks.Sepolia,
testutils.TransactionBuilder.GetTestDeclareTransaction,
testutils.TransactionBuilder.GetTestDeployAccountTransaction,
testutils.TransactionBuilder.GetTestInvokeTransaction,
Expand All @@ -29,7 +29,7 @@ func TestAdaptTransaction(t *testing.T) {
require.Equal(t, p2pTransactions[i], convertedP2PTransaction)

convertedmempoolTransaction, err := p2p2mempool.AdaptTransaction(
t.Context(), compiler.NewUnsafe(), convertedP2PTransaction, &utils.Sepolia,
t.Context(), compiler.NewUnsafe(), convertedP2PTransaction, &networks.Sepolia,
)
require.NoError(t, err)

Expand Down
8 changes: 4 additions & 4 deletions adapters/p2p2consensus/p2p_consensus_adapters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/NethermindEth/juno/adapters/consensus2p2p/testutils"
"github.com/NethermindEth/juno/adapters/p2p2consensus"
transactiontestutils "github.com/NethermindEth/juno/adapters/testutils"
"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
"github.com/starknet-io/starknet-p2p-specs/p2p/proto/consensus/consensus"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -45,7 +45,7 @@ func TestAdaptProposalCommitment(t *testing.T) {
func TestAdaptProposalTransaction(t *testing.T) {
consensusTransactions, p2pTransactions := transactiontestutils.GetTestTransactions(
t,
&utils.Mainnet,
&networks.Mainnet,
testutils.TransactionBuilder.GetTestDeclareTransaction,
testutils.TransactionBuilder.GetTestDeployAccountTransaction,
testutils.TransactionBuilder.GetTestInvokeTransaction,
Expand All @@ -55,7 +55,7 @@ func TestAdaptProposalTransaction(t *testing.T) {
for i := range consensusTransactions {
t.Run(fmt.Sprintf("%T", consensusTransactions[i].Transaction), func(t *testing.T) {
convertedConsensusTransaction, err := p2p2consensus.AdaptTransaction(
t.Context(), compiler.NewUnsafe(), p2pTransactions[i], &utils.Mainnet,
t.Context(), compiler.NewUnsafe(), p2pTransactions[i], &networks.Mainnet,
)
require.NoError(t, err)

Expand All @@ -74,7 +74,7 @@ func TestAdaptProposalTransaction(t *testing.T) {
Transactions: p2pTransactions,
}
convertedConsensusTransactions, err := p2p2consensus.AdaptProposalTransaction(
t.Context(), compiler.NewUnsafe(), &transactionBatch, &utils.Mainnet,
t.Context(), compiler.NewUnsafe(), &transactionBatch, &networks.Mainnet,
)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions adapters/p2p2consensus/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (

"github.com/Masterminds/semver/v3"
"github.com/NethermindEth/juno/adapters/p2p2core"
"github.com/NethermindEth/juno/blockchain/networks"
consensus "github.com/NethermindEth/juno/consensus/types"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
p2pconsensus "github.com/starknet-io/starknet-p2p-specs/p2p/proto/consensus/consensus"
)

Expand Down Expand Up @@ -62,7 +62,7 @@ func AdaptProposalTransaction(
ctx context.Context,
compiler compiler.Compiler,
msg *p2pconsensus.TransactionBatch,
network *utils.Network,
network *networks.Network,
) ([]consensus.Transaction, error) {
var err error
txns := make([]consensus.Transaction, len(msg.Transactions))
Expand Down
4 changes: 2 additions & 2 deletions adapters/p2p2consensus/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (
"fmt"

"github.com/NethermindEth/juno/adapters/p2p2core"
"github.com/NethermindEth/juno/blockchain/networks"
consensus "github.com/NethermindEth/juno/consensus/types"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
p2pconsensus "github.com/starknet-io/starknet-p2p-specs/p2p/proto/consensus/consensus"
)

func AdaptTransaction(
ctx context.Context,
compiler compiler.Compiler,
t *p2pconsensus.ConsensusTransaction,
network *utils.Network,
network *networks.Network,
) (consensus.Transaction, error) {
if err := validateConsensusTransaction(t); err != nil {
return consensus.Transaction{}, err
Expand Down
3 changes: 2 additions & 1 deletion adapters/p2p2core/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/starknet/compiler"
Expand Down Expand Up @@ -358,7 +359,7 @@ func AdaptL1Handler(tx *transaction.L1HandlerV0, txnHash *common.Hash) *core.L1H

func AdaptTransaction(
t *synctransaction.TransactionInBlock,
network *utils.Network,
network *networks.Network,
) (core.Transaction, error) {
// can Txn be nil?

Expand Down
6 changes: 3 additions & 3 deletions adapters/p2p2core/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/NethermindEth/juno/adapters/core2p2p"
"github.com/NethermindEth/juno/adapters/p2p2core"
transactiontestutils "github.com/NethermindEth/juno/adapters/testutils"
"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/utils"
"github.com/starknet-io/starknet-p2p-specs/p2p/proto/common"
synctransaction "github.com/starknet-io/starknet-p2p-specs/p2p/proto/sync/transaction"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -146,7 +146,7 @@ var SyncTransactionBuilder = transactiontestutils.SyncTransactionBuilder[
func TestAdaptTransactionInBlock(t *testing.T) {
consensusTransactions, p2pTransactions := transactiontestutils.GetTestTransactions(
t,
&utils.Mainnet,
&networks.Mainnet,
SyncTransactionBuilder.GetTestDeclareV0Transaction,
SyncTransactionBuilder.GetTestDeclareV1Transaction,
SyncTransactionBuilder.GetTestDeclareV2Transaction,
Expand All @@ -163,7 +163,7 @@ func TestAdaptTransactionInBlock(t *testing.T) {
t.Run(fmt.Sprintf("%T", consensusTransactions[i].Hash()), func(t *testing.T) {
convertedConsensusTransaction, err := p2p2core.AdaptTransaction(
p2pTransactions[i],
&utils.Mainnet,
&networks.Mainnet,
)
require.NoError(t, err)
require.Equal(t, consensusTransactions[i], convertedConsensusTransaction)
Expand Down
6 changes: 3 additions & 3 deletions adapters/p2p2mempool/p2p_mempool_adapters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"github.com/NethermindEth/juno/adapters/mempool2p2p/testutils"
"github.com/NethermindEth/juno/adapters/p2p2mempool"
transactiontestutils "github.com/NethermindEth/juno/adapters/testutils"
"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
"github.com/stretchr/testify/require"
)

func TestAdaptProposalTransaction(t *testing.T) {
mempoolTransactions, p2pTransactions := transactiontestutils.GetTestTransactions(
t,
&utils.Sepolia,
&networks.Sepolia,
testutils.TransactionBuilder.GetTestDeclareTransaction,
testutils.TransactionBuilder.GetTestDeployAccountTransaction,
testutils.TransactionBuilder.GetTestInvokeTransaction,
Expand All @@ -25,7 +25,7 @@ func TestAdaptProposalTransaction(t *testing.T) {
for i := range mempoolTransactions {
t.Run(fmt.Sprintf("%T", mempoolTransactions[i].Transaction), func(t *testing.T) {
convertedmempoolTransaction, err := p2p2mempool.AdaptTransaction(
t.Context(), compiler.NewUnsafe(), p2pTransactions[i], &utils.Sepolia,
t.Context(), compiler.NewUnsafe(), p2pTransactions[i], &networks.Sepolia,
)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions adapters/p2p2mempool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"fmt"

"github.com/NethermindEth/juno/adapters/p2p2core"
"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/mempool"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
mempooltransaction "github.com/starknet-io/starknet-p2p-specs/p2p/proto/mempool/transaction"
)

Expand All @@ -31,7 +31,7 @@ func AdaptTransaction(
ctx context.Context,
compiler compiler.Compiler,
t *mempooltransaction.MempoolTransaction,
network *utils.Network,
network *networks.Network,
) (mempool.BroadcastedTransaction, error) {
if err := validateMempoolTransaction(t); err != nil {
return mempool.BroadcastedTransaction{}, err
Expand Down
36 changes: 18 additions & 18 deletions adapters/sn2core/sn2core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"testing"

"github.com/NethermindEth/juno/adapters/sn2core"
"github.com/NethermindEth/juno/blockchain/networks"
"github.com/NethermindEth/juno/clients/feeder"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/core/pending"
"github.com/NethermindEth/juno/starknet"
"github.com/NethermindEth/juno/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -19,7 +19,7 @@ func TestAdaptBlock(t *testing.T) {
tests := []struct {
number uint64
protocolVersion string
network utils.Network
network networks.Network
sig *starknet.Signature
l1GasPriceWEI *felt.Felt
l1GasPriceSTRK *felt.Felt
Expand All @@ -30,27 +30,27 @@ func TestAdaptBlock(t *testing.T) {
}{
{
number: 147,
network: utils.Mainnet,
network: networks.Mainnet,
l1GasPriceWEI: &felt.Zero,
},
{
number: 11817,
protocolVersion: "0.10.1",
network: utils.Mainnet,
network: networks.Mainnet,
l1GasPriceWEI: felt.NewUnsafeFromString[felt.Felt]("0x27ad16775"),
},
{
number: 304740,
protocolVersion: "0.12.1",
network: utils.Integration,
network: networks.Integration,
sig: &starknet.Signature{
Signature: []*felt.Felt{felt.NewUnsafeFromString[felt.Felt]("0x44"), felt.NewUnsafeFromString[felt.Felt]("0x37")},
},
l1GasPriceWEI: felt.NewUnsafeFromString[felt.Felt]("0x3bb2acbc"),
},
{
number: 319132,
network: utils.Integration,
network: networks.Integration,
protocolVersion: "0.13.0",
sig: &starknet.Signature{
Signature: []*felt.Felt{
Expand All @@ -63,7 +63,7 @@ func TestAdaptBlock(t *testing.T) {
},
{
number: 330363,
network: utils.Integration,
network: networks.Integration,
protocolVersion: "0.13.1",
sig: &starknet.Signature{
Signature: []*felt.Felt{
Expand All @@ -78,7 +78,7 @@ func TestAdaptBlock(t *testing.T) {
},
{
number: 64164,
network: utils.SepoliaIntegration,
network: networks.SepoliaIntegration,
protocolVersion: "0.13.4",
sig: &starknet.Signature{
Signature: []*felt.Felt{
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestAdaptBlock(t *testing.T) {
func TestStateUpdate(t *testing.T) {
numbers := []uint64{0, 1, 2, 21656}

client := feeder.NewTestClient(t, &utils.Mainnet)
client := feeder.NewTestClient(t, &networks.Mainnet)
ctx := t.Context()

for _, number := range numbers {
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestStateUpdate(t *testing.T) {
}

t.Run("v0.11.0 state update", func(t *testing.T) {
integClient := feeder.NewTestClient(t, &utils.Integration)
integClient := feeder.NewTestClient(t, &networks.Integration)

t.Run("declared Cairo0 classes", func(t *testing.T) {
feederUpdate, err := integClient.StateUpdate(ctx, "283746")
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestClassV0(t *testing.T) {
"0x28d1671fb74ecb54d848d463cefccffaef6df3ae40db52130e19fe8299a7b43",
}

client := feeder.NewTestClient(t, &utils.Sepolia)
client := feeder.NewTestClient(t, &networks.Sepolia)
ctx := t.Context()

for _, hashString := range classHashes {
Expand Down Expand Up @@ -291,8 +291,8 @@ func TestClassV0(t *testing.T) {
}

func TestTransaction(t *testing.T) {
clientGoerli := feeder.NewTestClient(t, &utils.Goerli)
clientMainnet := feeder.NewTestClient(t, &utils.Mainnet)
clientGoerli := feeder.NewTestClient(t, &networks.Goerli)
clientMainnet := feeder.NewTestClient(t, &networks.Mainnet)
ctx := t.Context()

t.Run("invoke transaction", func(t *testing.T) {
Expand Down Expand Up @@ -403,7 +403,7 @@ func TestTransaction(t *testing.T) {
}

func TestTransactionV3(t *testing.T) {
client := feeder.NewTestClient(t, &utils.Integration)
client := feeder.NewTestClient(t, &networks.Integration)
ctx := t.Context()

tests := map[string]core.Transaction{
Expand Down Expand Up @@ -539,19 +539,19 @@ func TestClassV1(t *testing.T) {
tests := []struct {
name string
classHash string
network *utils.Network
network *networks.Network
expectedSierraVersion string
}{
{
name: "cairo one class adapt sierra version 0.1.0",
classHash: "0x1cd2edfb485241c4403254d550de0a097fa76743cd30696f714a491a454bad5",
network: &utils.Integration,
network: &networks.Integration,
expectedSierraVersion: "0.1.0",
},
{
name: "cairo one class adapt sierra version 1.6.0",
classHash: "0x03cc90db763e736ca9b6c581ea4008408842b1a125947ab087438676a7e40b7b",
network: &utils.Sepolia,
network: &networks.Sepolia,
expectedSierraVersion: "1.6.0",
},
}
Expand Down Expand Up @@ -637,7 +637,7 @@ func TestAdaptCompiledClass(t *testing.T) {
}

func TestAdaptPreConfirmed(t *testing.T) {
n := &utils.SepoliaIntegration
n := &networks.SepoliaIntegration
client := feeder.NewTestClient(t, n)
emptyPreConfirmedBlock := uint64(1201960)
blockWithCandidates := uint64(1204672)
Expand Down
Loading
Loading