Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
evlekht committed Jul 24, 2024
1 parent ed2ae4a commit a5c21b3
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion vms/platformvm/camino_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
14 changes: 7 additions & 7 deletions vms/platformvm/network/camino_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 2 additions & 3 deletions vms/platformvm/state/test/camino_test_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -34,7 +33,7 @@ func State(
db,
genesisBytes,
prometheus.NewRegistry(),
validators,
cfg,
execCfg,
ctx,
metrics.Noop,
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_add_deposit_offer_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_add_proposal_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}}}
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_add_vote_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_claim_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_deposit_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_finish_proposals_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_multisig_alias_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_register_node_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_rewards_import_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/camino_unlock_deposit_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/executor/camino_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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{
Expand Down
1 change: 0 additions & 1 deletion vms/platformvm/txs/executor/camino_tx_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions vms/platformvm/utxo/camino_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/utxo/camino_locked_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a5c21b3

Please sign in to comment.