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
64 changes: 60 additions & 4 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,65 @@ template: testify
packages:
github.com/wavesplatform/gowaves/pkg/networking:
interfaces:
Handler: {}
Header: {}
Protocol: {}
Handler: { }
Header: { }
Protocol: { }
github.com/wavesplatform/gowaves/pkg/blockchaininfo:
interfaces:
UpdatesPublisherInterface: {}
UpdatesPublisherInterface: { }
github.com/wavesplatform/gowaves/pkg/state:
interfaces:
State:
config:
filename: mock_state.go
scriptStorageState:
config:
structname: MockScriptStorageState
filename: mock_script_storage_state_test.go
featuresState:
config:
structname: MockFeaturesState
filename: mock_features_state_test.go
github.com/wavesplatform/gowaves/pkg/consensus:
interfaces:
stateInfoProvider:
config:
filename: mock_state_info_provider_test.go
github.com/wavesplatform/gowaves/pkg/ride:
interfaces:
environment:
config:
structname: MockEnvironment
filename: mock_environment_test.go
github.com/wavesplatform/gowaves/pkg/grpc/server:
interfaces:
GrpcHandlers:
config:
filename: mock_grpc_handlers_test.go
github.com/wavesplatform/gowaves/pkg/node/peers:
interfaces:
PeerManager:
config:
filename: mock_peer_manager.go
PeerStorage:
config:
filename: mock_peer_storage_test.go
github.com/wavesplatform/gowaves/pkg/p2p/conn:
interfaces:
deadlineReader:
config:
structname: MockDeadlineReader
filename: mock_deadline_reader_test.go
github.com/wavesplatform/gowaves/pkg/p2p/peer:
interfaces:
Peer:
config:
filename: mock_peer_exported.go
github.com/wavesplatform/gowaves/pkg/types:
interfaces:
SmartState:
config:
filename: mock_smart_state.go
EnrichedSmartState:
config:
filename: mock_enriched_smart_state.go
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@ dist: clean dist-chaincmp dist-importer dist-node dist-wallet dist-compiler
build: vendor ver build-chaincmp-native build-blockcmp-native build-node-native build-importer-native build-wallet-native build-rollback-native build-compiler-native build-statehash-native build-convert-native

mock:
mockgen -source pkg/miner/utxpool/cleaner.go -destination pkg/miner/utxpool/mock.go -package utxpool stateWrapper
mockgen -source pkg/node/peers/peer_manager.go -destination pkg/mock/peer_manager.go -package mock PeerManager
mockgen -source pkg/node/peers/peer_storage.go -destination pkg/mock/peer_storage.go -package mock PeerStorage
mockgen -source pkg/p2p/peer/peer.go -destination pkg/mock/peer.go -package mock Peer
mockgen -source pkg/state/api.go -destination pkg/mock/state.go -package mock State
mockgen -source pkg/grpc/server/api.go -destination pkg/mock/grpc.go -package mock GrpcHandlers
mockery

proto:
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require (
github.com/fxamacker/cbor/v2 v2.9.0
github.com/go-chi/chi/v5 v5.2.5
github.com/go-test/deep v1.1.1
github.com/golang/mock v1.6.0
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c
github.com/jinzhu/copier v0.4.0
Expand Down
14 changes: 0 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -332,7 +330,6 @@ github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQ
github.com/xenolf/lego v2.7.2+incompatible h1:aGxxYqhnQLQ71HsvEAjJVw6ao14APwPpRk0mpFroPXk=
github.com/xenolf/lego v2.7.2+incompatible/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=
Expand Down Expand Up @@ -365,22 +362,19 @@ golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtC
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -391,9 +385,6 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -402,24 +393,19 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU=
golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200729173947-1c30660f9f89/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@ import (
"encoding/json"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/wavesplatform/gowaves/pkg/crypto"
"github.com/wavesplatform/gowaves/pkg/mock"
"github.com/wavesplatform/gowaves/pkg/proto"
"github.com/wavesplatform/gowaves/pkg/services"
"github.com/wavesplatform/gowaves/pkg/state"
)

func TestApp_BlocksFirst(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

g := &proto.Block{
BlockHeader: proto.BlockHeader{
BlockSignature: crypto.MustSignatureFromBase58("5uqnLK3Z9eiot6FyYBfwUnbyid3abicQbAZjz38GQ1Q8XigQMxTK4C1zNkqS1SVw7FqSidbZKxWAKLVoEsp4nNqa"),
},
}

s := mock.NewMockState(ctrl)
s := state.NewMockState(t)
s.EXPECT().BlockByHeight(proto.Height(1)).Return(g, nil)

app, err := NewApp("api-key", nil, services.Services{State: s})
Expand All @@ -35,10 +31,7 @@ func TestApp_BlocksFirst(t *testing.T) {
func TestApp_BlocksLast(t *testing.T) {
g := &proto.Block{}

ctrl := gomock.NewController(t)
defer ctrl.Finish()

s := mock.NewMockState(ctrl)
s := state.NewMockState(t)
s.EXPECT().Height().Return(proto.Height(1), nil)
s.EXPECT().BlockByHeight(proto.Height(1)).Return(g, nil)

Expand Down
10 changes: 3 additions & 7 deletions pkg/api/node_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import (
"testing"

"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

apiErrs "github.com/wavesplatform/gowaves/pkg/api/errors"
"github.com/wavesplatform/gowaves/pkg/mock"
"github.com/wavesplatform/gowaves/pkg/proto"
"github.com/wavesplatform/gowaves/pkg/services"
"github.com/wavesplatform/gowaves/pkg/state"
)

const apiKey = "X-API-Key"
Expand Down Expand Up @@ -83,8 +82,7 @@ func TestNodeApi_WavesRegularBalanceByAddress(t *testing.T) {
addr, err := proto.NewAddressFromString(addrStr)
require.NoError(t, err)

ctrl := gomock.NewController(t)
st := mock.NewMockState(ctrl)
st := state.NewMockState(t)
st.EXPECT().WavesBalance(proto.NewRecipientFromAddress(addr)).Return(uint64(1000), nil).Times(1)

resp := httptest.NewRecorder()
Expand Down Expand Up @@ -112,13 +110,11 @@ func TestNodeApi_WavesRegularBalanceByAddress(t *testing.T) {

t.Run("error", func(t *testing.T) {
doTest := func(t *testing.T, addrStr string) {
ctrl := gomock.NewController(t)

resp := httptest.NewRecorder()
req := createRequest(addrStr)

a, err := NewApp("", nil, services.Services{
State: mock.NewMockState(ctrl),
State: state.NewMockState(t),
Scheme: proto.TestNetScheme,
})
require.NoError(t, err)
Expand Down
22 changes: 5 additions & 17 deletions pkg/api/peers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/wavesplatform/gowaves/pkg/node/peers"
"github.com/wavesplatform/gowaves/pkg/node/peers/storage"
"github.com/wavesplatform/gowaves/pkg/proto"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/wavesplatform/gowaves/pkg/mock"
"github.com/wavesplatform/gowaves/pkg/services"
)

func TestApp_PeersKnown(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

peerManager := mock.NewMockPeerManager(ctrl)
peerManager := peers.NewMockPeerManager(t)
addr := proto.NewTCPAddr(net.ParseIP("127.0.0.1"), 6868).ToIpPort()
peerManager.EXPECT().KnownPeers().Return([]storage.KnownPeer{storage.KnownPeer(addr)})

Expand All @@ -34,10 +28,7 @@ func TestApp_PeersKnown(t *testing.T) {
}

func TestApp_PeersSuspended(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

peerManager := mock.NewMockPeerManager(ctrl)
peerManager := peers.NewMockPeerManager(t)

now := time.Now()

Expand Down Expand Up @@ -76,10 +67,7 @@ func TestApp_PeersSuspended(t *testing.T) {
}

func TestApp_PeersBlackList(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

peerManager := mock.NewMockPeerManager(ctrl)
peerManager := peers.NewMockPeerManager(t)

now := time.Now()

Expand Down
1 change: 0 additions & 1 deletion pkg/consensus/blocks_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func isInvalidMainNetBlock(blockID proto.BlockID, height uint64) bool {
return false
}

//go:generate moq -out validator_moq_test.go . stateInfoProvider
type stateInfoProvider interface {
HeaderByHeight(height uint64) (*proto.BlockHeader, error)
NewestHitSourceAtHeight(height uint64) ([]byte, error)
Expand Down
33 changes: 18 additions & 15 deletions pkg/consensus/blocks_validation_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/wavesplatform/gowaves/pkg/crypto"
Expand Down Expand Up @@ -56,20 +57,21 @@ func TestValidator_ShouldIncludeNewBlockFieldsOfLightNodeFeature(t *testing.T) {
}
for i, tt := range tests {
t.Run(strconv.Itoa(i+1), func(t *testing.T) {
sip := &stateInfoProviderMock{
NewestIsActiveAtHeightFunc: func(featureID int16, height uint64) (bool, error) {
m := NewMockstateInfoProvider(t)
m.EXPECT().NewestIsActiveAtHeight(mock.Anything, mock.Anything).RunAndReturn(
func(featureID int16, height uint64) (bool, error) {
require.Equal(t, int16(settings.LightNode), featureID)
require.Equal(t, tt.blockHeight, height)
return tt.lightNodeIsActiveAtHeight, nil
},
NewestActivationHeightFunc: func(featureID int16) (uint64, error) {
}).Maybe()
m.EXPECT().NewestActivationHeight(mock.Anything).RunAndReturn(
func(featureID int16) (uint64, error) {
require.Equal(t, int16(settings.LightNode), featureID)
return tt.lightNodeActivationHeight, nil
},
}
sets := settings.MustTestNetSettings() // copy of testnet settings
}).Maybe()
sets := settings.MustTestNetSettings() // copy of Testnet settings
sets.LightNodeBlockFieldsAbsenceInterval = tt.lightNodeBlockFieldsAbsenceInterval
v := NewValidator(sip, sets, timeMock{})
v := NewValidator(m, sets, timeMock{})
result, err := v.ShouldIncludeNewBlockFieldsOfLightNodeFeature(tt.blockHeight)
require.NoError(t, err)
assert.Equal(t, tt.expectedResult, result)
Expand Down Expand Up @@ -165,18 +167,19 @@ func TestValidator_validateLightNodeBlockFields(t *testing.T) {
}
for i, tt := range tests {
t.Run(strconv.Itoa(i+1), func(t *testing.T) {
sip := &stateInfoProviderMock{
NewestIsActiveAtHeightFunc: func(featureID int16, height uint64) (bool, error) {
sip := NewMockstateInfoProvider(t)
sip.EXPECT().NewestIsActiveAtHeight(mock.Anything, mock.Anything).RunAndReturn(
func(featureID int16, height uint64) (bool, error) {
require.Equal(t, int16(settings.LightNode), featureID)
require.Equal(t, tt.blockHeight, height)
return tt.lightNodeIsActiveAtHeight, nil
},
NewestActivationHeightFunc: func(featureID int16) (uint64, error) {
}).Maybe()
sip.EXPECT().NewestActivationHeight(mock.Anything).RunAndReturn(
func(featureID int16) (uint64, error) {
require.Equal(t, int16(settings.LightNode), featureID)
return tt.lightNodeActivationHeight, nil
},
}
sets := settings.MustTestNetSettings() // copy of testnet settings
}).Maybe()
sets := settings.MustTestNetSettings() // copy of Testnet settings
sets.LightNodeBlockFieldsAbsenceInterval = tt.lightNodeBlockFieldsAbsenceInterval
v := NewValidator(sip, sets, timeMock{})
err := v.validateLightNodeBlockFields(&tt.blockHeader, tt.blockHeight)
Expand Down
Loading
Loading