diff --git a/vms/platformvm/camino_vm_test.go b/vms/platformvm/camino_vm_test.go index a16730a3bc05..efe8fb44c6d9 100644 --- a/vms/platformvm/camino_vm_test.go +++ b/vms/platformvm/camino_vm_test.go @@ -625,7 +625,7 @@ func TestProposals(t *testing.T) { vm.clock.Set(baseFeeProposalState.StartTime().Add(-time.Second)) addVoteTx := buildSimpleVoteTx(t, vm, proposerKey, fee, proposalTx.ID(), test.FundedKeys[0], 0) err = vm.Network.IssueTx(context.Background(), addVoteTx) - require.ErrorIs(err, txexecutor.ErrProposalInactive) + require.ErrorIs(err, dac.ErrNotYetActive) vm.clock.Set(baseFeeProposalState.StartTime()) optionWeights := make([]uint32, len(baseFeeProposalState.Options)) diff --git a/vms/platformvm/network/camino_network.go b/vms/platformvm/network/camino_network.go index a6c5dd2daba6..be24529d276d 100644 --- a/vms/platformvm/network/camino_network.go +++ b/vms/platformvm/network/camino_network.go @@ -121,22 +121,22 @@ func (n *caminoNetwork) caminoRewardMessage() string { return fmt.Sprintf("caminoCrossChainAppRequest failed to issue rewardsImportTx: %s", err) } - amounts := make([]uint64, len(utx.Ins)) + amts := make([]uint64, len(utx.Ins)) for i := range utx.Ins { - amounts[i] = utx.Ins[i].In.Amount() + amts[i] = utx.Ins[i].In.Amount() } - return fmt.Sprintf("caminoCrossChainAppRequest issued rewardsImportTx with utxos with %v nCAM", amounts) + return fmt.Sprintf("caminoCrossChainAppRequest issued rewardsImportTx with utxos with %v nCAM", amts) } -func (n *caminoNetwork) newRewardsImportTx() *txs.Tx { +func (n *caminoNetwork) newRewardsImportTx() (*txs.Tx, error) { n.lock.Lock() defer n.lock.Unlock() tx, err := n.txBuilder.NewRewardsImportTx() if err != nil { - n.log.Error("caminoCrossChainAppRequest couldn't create rewardsImportTx", zap.Error(err)) - return nil // we don't want fatal here + n.log.Error("caminoCrossChainAppRequest failed to create rewardsImportTx", zap.Error(err)) + return nil, fmt.Errorf("caminoCrossChainAppRequest failed to create rewardsImportTx: %w", err) } - return tx + return tx, nil } diff --git a/vms/platformvm/state/test/camino_test_state.go b/vms/platformvm/state/test/camino_test_state.go index 5f9951b7c561..1f6c72f8e528 100644 --- a/vms/platformvm/state/test/camino_test_state.go +++ b/vms/platformvm/state/test/camino_test_state.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/vms/platformvm/api" "github.com/ava-labs/avalanchego/vms/platformvm/config" "github.com/ava-labs/avalanchego/vms/platformvm/metrics" @@ -21,7 +20,7 @@ import ( func State( t *testing.T, - validators validators.Manager, + cfg *config.Config, ctx *snow.Context, db database.Database, rewards reward.Calculator, @@ -34,7 +33,7 @@ func State( db, genesisBytes, prometheus.NewRegistry(), - validators, + cfg, execCfg, ctx, metrics.Noop, diff --git a/vms/platformvm/txs/camino_add_deposit_offer_tx_test.go b/vms/platformvm/txs/camino_add_deposit_offer_tx_test.go index 15474fb9cadd..cf0d27d04704 100644 --- a/vms/platformvm/txs/camino_add_deposit_offer_tx_test.go +++ b/vms/platformvm/txs/camino_add_deposit_offer_tx_test.go @@ -11,16 +11,16 @@ import ( "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/deposit" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestAddDepositOfferTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) owner1 := secp256k1fx.OutputOwners{Threshold: 1, Addrs: []ids.ShortID{{0, 0, 1}}} depositTxID := ids.ID{0, 1} creatorAddress := ids.ShortID{1} diff --git a/vms/platformvm/txs/camino_add_proposal_tx_test.go b/vms/platformvm/txs/camino_add_proposal_tx_test.go index 33479d62db8c..aac1b24b6b3c 100644 --- a/vms/platformvm/txs/camino_add_proposal_tx_test.go +++ b/vms/platformvm/txs/camino_add_proposal_tx_test.go @@ -9,17 +9,17 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/dac" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" "github.com/ava-labs/avalanchego/vms/types" ) func TestAddProposalTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) owner1 := secp256k1fx.OutputOwners{Threshold: 1, Addrs: []ids.ShortID{{0, 0, 1}}} badProposal := &ProposalWrapper{Proposal: &dac.BaseFeeProposal{Options: []uint64{}}} diff --git a/vms/platformvm/txs/camino_add_vote_tx_test.go b/vms/platformvm/txs/camino_add_vote_tx_test.go index d2621784fc64..ff56b0e74940 100644 --- a/vms/platformvm/txs/camino_add_vote_tx_test.go +++ b/vms/platformvm/txs/camino_add_vote_tx_test.go @@ -9,16 +9,16 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/dac" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestAddVoteTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) owner1 := secp256k1fx.OutputOwners{Threshold: 1, Addrs: []ids.ShortID{{0, 0, 1}}} badVote := &VoteWrapper{Vote: &dac.DummyVote{ErrorStr: "test errr"}} diff --git a/vms/platformvm/txs/camino_claim_tx_test.go b/vms/platformvm/txs/camino_claim_tx_test.go index 29a69de0172f..2d81ed894a1d 100644 --- a/vms/platformvm/txs/camino_claim_tx_test.go +++ b/vms/platformvm/txs/camino_claim_tx_test.go @@ -9,15 +9,15 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestClaimTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) owner1 := secp256k1fx.OutputOwners{Threshold: 1, Addrs: []ids.ShortID{{0, 0, 1}}} depositTxID := ids.ID{0, 1} claimableOwnerID1 := ids.ID{0, 2} diff --git a/vms/platformvm/txs/camino_deposit_tx_test.go b/vms/platformvm/txs/camino_deposit_tx_test.go index 35e224e2b9de..4d032c6ba7c8 100644 --- a/vms/platformvm/txs/camino_deposit_tx_test.go +++ b/vms/platformvm/txs/camino_deposit_tx_test.go @@ -11,15 +11,15 @@ import ( "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestDepositTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) owner1 := secp256k1fx.OutputOwners{Threshold: 1, Addrs: []ids.ShortID{{1}}} tests := map[string]struct { diff --git a/vms/platformvm/txs/camino_finish_proposals_tx_test.go b/vms/platformvm/txs/camino_finish_proposals_tx_test.go index 1a47675ea28b..2c8cda0056bb 100644 --- a/vms/platformvm/txs/camino_finish_proposals_tx_test.go +++ b/vms/platformvm/txs/camino_finish_proposals_tx_test.go @@ -9,15 +9,15 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestFinishProposalsTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) owner1 := secp256k1fx.OutputOwners{Threshold: 1, Addrs: []ids.ShortID{{0, 0, 1}}} proposalID1 := ids.ID{1} diff --git a/vms/platformvm/txs/camino_multisig_alias_tx_test.go b/vms/platformvm/txs/camino_multisig_alias_tx_test.go index 443a66326bdd..f5bfce4ba160 100644 --- a/vms/platformvm/txs/camino_multisig_alias_tx_test.go +++ b/vms/platformvm/txs/camino_multisig_alias_tx_test.go @@ -11,14 +11,14 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/multisig" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestMultisigAliasTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) memo := []byte("memo") bigMemo := make([]byte, 257) diff --git a/vms/platformvm/txs/camino_register_node_tx_test.go b/vms/platformvm/txs/camino_register_node_tx_test.go index 5fc2be5d1339..9082904bfdfa 100644 --- a/vms/platformvm/txs/camino_register_node_tx_test.go +++ b/vms/platformvm/txs/camino_register_node_tx_test.go @@ -9,15 +9,15 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestRegisterNodeTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) owner1 := secp256k1fx.OutputOwners{Threshold: 1, Addrs: []ids.ShortID{{0, 1}}} depositTxID := ids.ID{1} diff --git a/vms/platformvm/txs/camino_rewards_import_tx_test.go b/vms/platformvm/txs/camino_rewards_import_tx_test.go index 23cb3801bb97..bfba38f23af2 100644 --- a/vms/platformvm/txs/camino_rewards_import_tx_test.go +++ b/vms/platformvm/txs/camino_rewards_import_tx_test.go @@ -9,14 +9,14 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" ) func TestRewardsImportTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) tests := map[string]struct { tx *RewardsImportTx diff --git a/vms/platformvm/txs/camino_unlock_deposit_tx_test.go b/vms/platformvm/txs/camino_unlock_deposit_tx_test.go index 66e9e869676b..52fb3ba51e3b 100644 --- a/vms/platformvm/txs/camino_unlock_deposit_tx_test.go +++ b/vms/platformvm/txs/camino_unlock_deposit_tx_test.go @@ -9,15 +9,15 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/locked" - "github.com/ava-labs/avalanchego/vms/platformvm/test" "github.com/ava-labs/avalanchego/vms/platformvm/test/generate" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) func TestUnlockDepositTxSyntacticVerify(t *testing.T) { - ctx := test.Context(t) + ctx := snowtest.Context(t, snowtest.PChainID) tests := map[string]struct { tx *UnlockDepositTx diff --git a/vms/platformvm/txs/executor/camino_helpers_test.go b/vms/platformvm/txs/executor/camino_helpers_test.go index 33deb1afeaa1..2acbfb2f1e0d 100644 --- a/vms/platformvm/txs/executor/camino_helpers_test.go +++ b/vms/platformvm/txs/executor/camino_helpers_test.go @@ -53,7 +53,7 @@ func newCaminoEnvironment(t *testing.T, phase test.Phase, caminoGenesisConf api. rewards := reward.NewCalculator(config.RewardConfig) genesisBytes := test.Genesis(t, ctx.AVAXAssetID, caminoGenesisConf, nil) - baseState := testState.State(t, config.Validators, ctx, baseDB, rewards, genesisBytes) + baseState := testState.State(t, config, ctx, baseDB, rewards, genesisBytes) atomicUTXOs := avax.NewAtomicUTXOManager(ctx.SharedMemory, txs.Codec) uptimes := uptime.NewManager(baseState, clk) @@ -193,7 +193,7 @@ func newExecutorBackend( rewards := reward.NewCalculator(config.RewardConfig) genesisBytes := test.Genesis(t, ctx.AVAXAssetID, caminoGenesisConf, nil) - state := testState.State(t, config.Validators, ctx, baseDB, rewards, genesisBytes) + state := testState.State(t, config, ctx, baseDB, rewards, genesisBytes) if sharedMemory != nil { ctx.SharedMemory = &mutableSharedMemory{ diff --git a/vms/platformvm/txs/executor/camino_tx_executor_test.go b/vms/platformvm/txs/executor/camino_tx_executor_test.go index ce4868f10073..e26375edd9ff 100644 --- a/vms/platformvm/txs/executor/camino_tx_executor_test.go +++ b/vms/platformvm/txs/executor/camino_tx_executor_test.go @@ -16,7 +16,6 @@ import ( "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" diff --git a/vms/platformvm/utxo/camino_helpers_test.go b/vms/platformvm/utxo/camino_helpers_test.go index e1b08730104c..2cbe4a42d7de 100644 --- a/vms/platformvm/utxo/camino_helpers_test.go +++ b/vms/platformvm/utxo/camino_helpers_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/avalanchego/codec/linearcodec" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/hashing" "github.com/ava-labs/avalanchego/utils/logging" @@ -52,7 +51,7 @@ func defaultCaminoHandler(t *testing.T) *caminoHandler { return &caminoHandler{ handler: handler{ - ctx: snow.DefaultContextTest(), + ctx: test.Context(t), clk: clk, fx: fx, }, diff --git a/vms/platformvm/utxo/camino_locked_test.go b/vms/platformvm/utxo/camino_locked_test.go index 06ccedcaea1c..b3d3281c6326 100644 --- a/vms/platformvm/utxo/camino_locked_test.go +++ b/vms/platformvm/utxo/camino_locked_test.go @@ -159,7 +159,7 @@ func TestLock(t *testing.T) { rewardsCalc := reward.NewCalculator(config.RewardConfig) genesisBytes := test.Genesis(t, ctx.AVAXAssetID, api.Camino{}, nil) - testState := stateTest.State(t, config.Validators, ctx, baseDB, rewardsCalc, genesisBytes) + testState := stateTest.State(t, config, ctx, baseDB, rewardsCalc, genesisBytes) key, err := secp256k1.NewPrivateKey() require.NoError(t, err)