Skip to content

Commit

Permalink
Rename avm/blocks package to avm/block (#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-kim authored Sep 18, 2023
1 parent b64d8ba commit 63271f8
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 143 deletions.
2 changes: 1 addition & 1 deletion scripts/mocks.mockgen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ github.com/ava-labs/avalanchego/utils/filesystem=Reader=utils/filesystem/mock_io
github.com/ava-labs/avalanchego/utils/hashing=Hasher=utils/hashing/mock_hasher.go
github.com/ava-labs/avalanchego/utils/logging=Logger=utils/logging/mock_logger.go
github.com/ava-labs/avalanchego/utils/resource=User=utils/resource/mock_user.go
github.com/ava-labs/avalanchego/vms/avm/blocks=Block=vms/avm/blocks/mock_block.go
github.com/ava-labs/avalanchego/vms/avm/block=Block=vms/avm/block/mock_block.go
github.com/ava-labs/avalanchego/vms/avm/metrics=Metrics=vms/avm/metrics/mock_metrics.go
github.com/ava-labs/avalanchego/vms/avm/states=Chain,State,Diff=vms/avm/states/mock_states.go
github.com/ava-labs/avalanchego/vms/avm/txs/mempool=Mempool=vms/avm/txs/mempool/mock_mempool.go
Expand Down
2 changes: 1 addition & 1 deletion vms/avm/blocks/block.go → vms/avm/block/block.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package blocks
package block

import (
"time"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package blocks
package block

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/timer/mockable"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/avm/blocks"
"github.com/ava-labs/avalanchego/vms/avm/block"
"github.com/ava-labs/avalanchego/vms/avm/states"
"github.com/ava-labs/avalanchego/vms/avm/txs"
"github.com/ava-labs/avalanchego/vms/avm/txs/mempool"

blockexecutor "github.com/ava-labs/avalanchego/vms/avm/blocks/executor"
blockexecutor "github.com/ava-labs/avalanchego/vms/avm/block/executor"
txexecutor "github.com/ava-labs/avalanchego/vms/avm/txs/executor"
)

Expand Down Expand Up @@ -153,7 +153,7 @@ func (b *builder) BuildBlock(context.Context) (snowman.Block, error) {
return nil, ErrNoTransactions
}

statelessBlk, err := blocks.NewStandardBlock(
statelessBlk, err := block.NewStandardBlock(
preferredID,
nextHeight,
nextTimestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/timer/mockable"
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/avalanchego/vms/avm/blocks"
"github.com/ava-labs/avalanchego/vms/avm/block"
"github.com/ava-labs/avalanchego/vms/avm/fxs"
"github.com/ava-labs/avalanchego/vms/avm/metrics"
"github.com/ava-labs/avalanchego/vms/avm/states"
Expand All @@ -36,7 +36,7 @@ import (
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"

blkexecutor "github.com/ava-labs/avalanchego/vms/avm/blocks/executor"
blkexecutor "github.com/ava-labs/avalanchego/vms/avm/block/executor"
txexecutor "github.com/ava-labs/avalanchego/vms/avm/txs/executor"
)

Expand Down Expand Up @@ -86,7 +86,7 @@ func TestBuilderBuildBlock(t *testing.T) {
preferredID := ids.GenerateTestID()
preferredHeight := uint64(1337)
preferredTimestamp := time.Now()
preferredBlock := blocks.NewMockBlock(ctrl)
preferredBlock := block.NewMockBlock(ctrl)
preferredBlock.EXPECT().Height().Return(preferredHeight)
preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp)

Expand Down Expand Up @@ -117,7 +117,7 @@ func TestBuilderBuildBlock(t *testing.T) {
preferredID := ids.GenerateTestID()
preferredHeight := uint64(1337)
preferredTimestamp := time.Now()
preferredBlock := blocks.NewMockBlock(ctrl)
preferredBlock := block.NewMockBlock(ctrl)
preferredBlock.EXPECT().Height().Return(preferredHeight)
preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp)

Expand Down Expand Up @@ -161,7 +161,7 @@ func TestBuilderBuildBlock(t *testing.T) {
preferredID := ids.GenerateTestID()
preferredHeight := uint64(1337)
preferredTimestamp := time.Now()
preferredBlock := blocks.NewMockBlock(ctrl)
preferredBlock := block.NewMockBlock(ctrl)
preferredBlock.EXPECT().Height().Return(preferredHeight)
preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp)

Expand Down Expand Up @@ -206,7 +206,7 @@ func TestBuilderBuildBlock(t *testing.T) {
preferredID := ids.GenerateTestID()
preferredHeight := uint64(1337)
preferredTimestamp := time.Now()
preferredBlock := blocks.NewMockBlock(ctrl)
preferredBlock := block.NewMockBlock(ctrl)
preferredBlock.EXPECT().Height().Return(preferredHeight)
preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp)

Expand Down Expand Up @@ -252,7 +252,7 @@ func TestBuilderBuildBlock(t *testing.T) {
preferredID := ids.GenerateTestID()
preferredHeight := uint64(1337)
preferredTimestamp := time.Now()
preferredBlock := blocks.NewMockBlock(ctrl)
preferredBlock := block.NewMockBlock(ctrl)
preferredBlock.EXPECT().Height().Return(preferredHeight)
preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp)

Expand Down Expand Up @@ -300,7 +300,7 @@ func TestBuilderBuildBlock(t *testing.T) {
// Assert created block has one tx, tx1,
// and other fields are set correctly.
manager.EXPECT().NewBlock(gomock.Any()).DoAndReturn(
func(block *blocks.StandardBlock) snowman.Block {
func(block *block.StandardBlock) snowman.Block {
require.Len(t, block.Transactions, 1)
require.Equal(t, tx1, block.Transactions[0])
require.Equal(t, preferredHeight+1, block.Height())
Expand Down Expand Up @@ -345,7 +345,7 @@ func TestBuilderBuildBlock(t *testing.T) {
preferredID := ids.GenerateTestID()
preferredHeight := uint64(1337)
preferredTimestamp := time.Now()
preferredBlock := blocks.NewMockBlock(ctrl)
preferredBlock := block.NewMockBlock(ctrl)
preferredBlock.EXPECT().Height().Return(preferredHeight)
preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp)

Expand All @@ -365,7 +365,7 @@ func TestBuilderBuildBlock(t *testing.T) {
manager.EXPECT().VerifyUniqueInputs(preferredID, gomock.Any()).Return(nil)
// Assert that the created block has the right timestamp
manager.EXPECT().NewBlock(gomock.Any()).DoAndReturn(
func(block *blocks.StandardBlock) snowman.Block {
func(block *block.StandardBlock) snowman.Block {
require.Equal(t, preferredTimestamp.Unix(), block.Timestamp().Unix())
return nil
},
Expand Down Expand Up @@ -419,7 +419,7 @@ func TestBuilderBuildBlock(t *testing.T) {
// preferred block's timestamp is after the time reported by clock
now := time.Now()
preferredTimestamp := now.Add(-2 * time.Second)
preferredBlock := blocks.NewMockBlock(ctrl)
preferredBlock := block.NewMockBlock(ctrl)
preferredBlock.EXPECT().Height().Return(preferredHeight)
preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp)

Expand All @@ -439,7 +439,7 @@ func TestBuilderBuildBlock(t *testing.T) {
manager.EXPECT().VerifyUniqueInputs(preferredID, gomock.Any()).Return(nil)
// Assert that the created block has the right timestamp
manager.EXPECT().NewBlock(gomock.Any()).DoAndReturn(
func(block *blocks.StandardBlock) snowman.Block {
func(block *block.StandardBlock) snowman.Block {
require.Equal(t, now.Unix(), block.Timestamp().Unix())
return nil
},
Expand Down Expand Up @@ -513,7 +513,7 @@ func TestBlockBuilderAddLocalTx(t *testing.T) {
require.NoError(mempool.Add(tx))
require.True(mempool.Has(txID))

parser, err := blocks.NewParser([]fxs.Fx{
parser, err := block.NewParser([]fxs.Fx{
&secp256k1fx.Fx{},
})
require.NoError(err)
Expand All @@ -539,7 +539,7 @@ func TestBlockBuilderAddLocalTx(t *testing.T) {
cm := parser.Codec()
txs, err := createParentTxs(cm)
require.NoError(err)
parentBlk, err := blocks.NewStandardBlock(parentID, 0, parentTimestamp, txs, cm)
parentBlk, err := block.NewStandardBlock(parentID, 0, parentTimestamp, txs, cm)
require.NoError(err)
state.AddBlock(parentBlk)
state.SetLastAccepted(parentBlk.ID())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/choices"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/vms/avm/blocks"
"github.com/ava-labs/avalanchego/vms/avm/block"
"github.com/ava-labs/avalanchego/vms/avm/states"
"github.com/ava-labs/avalanchego/vms/avm/txs/executor"
)
Expand All @@ -37,7 +37,7 @@ var (

// Exported for testing in avm package.
type Block struct {
blocks.Block
block.Block
manager *manager
rejected bool
}
Expand Down
Loading

0 comments on commit 63271f8

Please sign in to comment.