Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu committed Mar 27, 2024
1 parent 0a3f2d5 commit 81685d5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 30 deletions.
1 change: 0 additions & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func main() {
}

pChainBackend, err := pchain.NewBackend(
cfg.Mode,
pChainClient,
pIndexerParser,
avaxAssetID,
Expand Down
4 changes: 0 additions & 4 deletions service/backend/pchain/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ava-labs/avalanche-rosetta/client"
"github.com/ava-labs/avalanche-rosetta/constants"
"github.com/ava-labs/avalanche-rosetta/mapper"
"github.com/ava-labs/avalanche-rosetta/service"
"github.com/ava-labs/avalanche-rosetta/service/backend/pchain/indexer"

pmapper "github.com/ava-labs/avalanche-rosetta/mapper/pchain"
Expand Down Expand Up @@ -56,7 +55,6 @@ func TestAccountBalance(t *testing.T) {
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
parserMock.EXPECT().ParseNonGenesisBlock(ctx, "", blockHeight).Return(parsedBlock, nil).AnyTimes()
backend, err := NewBackend(
service.ModeOnline,
pChainMock,
parserMock,
avaxAssetID,
Expand Down Expand Up @@ -255,7 +253,6 @@ func TestAccountPendingRewardsBalance(t *testing.T) {
}

backend, err := NewBackend(
service.ModeOnline,
pChainMock,
parserMock,
avaxAssetID,
Expand Down Expand Up @@ -361,7 +358,6 @@ func TestAccountCoins(t *testing.T) {
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
parserMock.EXPECT().ParseNonGenesisBlock(ctx, "", blockHeight).Return(parsedBlock, nil).AnyTimes()
backend, err := NewBackend(
service.ModeOnline,
pChainMock,
parserMock,
avaxAssetID,
Expand Down
35 changes: 17 additions & 18 deletions service/backend/pchain/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ type Backend struct {

// NewBackend creates a P-chain service backend
func NewBackend(
nodeMode string,
pClient client.PChainClient,
indexerParser indexer.Parser,
assetID ids.ID,
avaxAssetID ids.ID,
networkIdentifier *types.NetworkIdentifier,
avalancheNetworkID uint32,
) (*Backend, error) {
Expand All @@ -50,29 +49,29 @@ func NewBackend(
return nil, err
}

networkHRP, err := mapper.GetHRP(networkIdentifier)
if err != nil {
return nil, err
}

b := &Backend{
genesisHandler: genHandler,
networkID: networkIdentifier,
networkHRP: networkHRP,
avalancheNetworkID: avalancheNetworkID,
pClient: pClient,
indexerParser: indexerParser,
getUTXOsPageSize: 1024,
codec: block.Codec,
codecVersion: block.CodecVersion,
indexerParser: indexerParser,
avaxAssetID: assetID,
avalancheNetworkID: avalancheNetworkID,
}

b.networkHRP, err = mapper.GetHRP(b.networkID)
if err != nil {
return nil, err
}

b.txParserCfg = pmapper.TxParserConfig{
IsConstruction: false,
Hrp: b.networkHRP,
ChainIDs: nil,
AvaxAssetID: b.avaxAssetID,
PChainClient: b.pClient,
avaxAssetID: avaxAssetID,
txParserCfg: pmapper.TxParserConfig{
IsConstruction: false,
Hrp: networkHRP,
ChainIDs: nil,
AvaxAssetID: avaxAssetID,
PChainClient: pClient,
},
}

return b, nil
Expand Down
1 change: 0 additions & 1 deletion service/backend/pchain/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func TestShouldHandleRequest(t *testing.T) {
parserMock := indexer.NewMockParser(ctrl)
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
backend, err := NewBackend(
service.ModeOnline,
clientMock,
parserMock,
avaxAssetID,
Expand Down
2 changes: 1 addition & 1 deletion service/backend/pchain/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestFetchBlkDependencies(t *testing.T) {
Encoding: formatting.Hex,
}).Return(nil, nil)

backend, err := NewBackend(service.ModeOnline, mockPClient, mockIndexerParser, avaxAssetID, networkIdentifier, networkID)
backend, err := NewBackend(mockPClient, mockIndexerParser, avaxAssetID, networkIdentifier, networkID)
require.NoError(t, err)

deps, err := backend.fetchBlkDependencies(ctx, []*txs.Tx{tx})
Expand Down
5 changes: 0 additions & 5 deletions service/backend/pchain/construction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func TestConstructionDerive(t *testing.T) {
parserMock := indexer.NewMockParser(ctrl)
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
backend, err := NewBackend(
service.ModeOnline,
pChainMock,
parserMock,
avaxAssetID,
Expand Down Expand Up @@ -193,7 +192,6 @@ func TestExportTxConstruction(t *testing.T) {
parserMock := indexer.NewMockParser(ctrl)
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
backend, err := NewBackend(
service.ModeOnline,
clientMock,
parserMock,
avaxAssetID,
Expand Down Expand Up @@ -404,7 +402,6 @@ func TestImportTxConstruction(t *testing.T) {
parserMock := indexer.NewMockParser(ctrl)
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
backend, err := NewBackend(
service.ModeOnline,
clientMock,
parserMock,
avaxAssetID,
Expand Down Expand Up @@ -645,7 +642,6 @@ func TestAddValidatorTxConstruction(t *testing.T) {
parserMock := indexer.NewMockParser(ctrl)
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
backend, err := NewBackend(
service.ModeOnline,
clientMock,
parserMock,
avaxAssetID,
Expand Down Expand Up @@ -880,7 +876,6 @@ func TestAddDelegatorTxConstruction(t *testing.T) {
parserMock := indexer.NewMockParser(ctrl)
parserMock.EXPECT().GetGenesisBlock(ctx).Return(dummyGenesis, nil)
backend, err := NewBackend(
service.ModeOnline,
clientMock,
parserMock,
avaxAssetID,
Expand Down

0 comments on commit 81685d5

Please sign in to comment.