Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Jun 6, 2023
1 parent d4463c3 commit b7e62c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
14 changes: 9 additions & 5 deletions genesis/parsing/accountsParser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/core/pubkeyConverter"
coreData "github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-core-go/data/outport"
Expand Down Expand Up @@ -515,10 +516,12 @@ func TestAccountsParser_getShardIDs(t *testing.T) {
}

func TestAccountsParser_createMintTransaction(t *testing.T) {
ap := parsing.NewTestAccountsParser(createMockHexPubkeyConverter())
pkConv, _ := pubkeyConverter.NewBech32PubkeyConverter(32, "erd")
expectedAddr, _ := pkConv.Decode("erd17rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rcqqkhty3")
ap := parsing.NewTestAccountsParser(pkConv)
balance := int64(1)
ibs := []*data.InitialAccount{
createSimpleInitialAccount("0001", balance),
createSimpleInitialAccount("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx", balance),
}

ap.SetEntireSupply(big.NewInt(int64(len(ibs)) * balance))
Expand All @@ -533,7 +536,7 @@ func TestAccountsParser_createMintTransaction(t *testing.T) {
assert.Equal(t, uint64(0), tx.GetNonce())
assert.Equal(t, ia[0].AddressBytes(), tx.GetRcvAddr())
assert.Equal(t, ia[0].GetSupply(), tx.GetValue())
assert.Equal(t, []byte("erd17rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rcqqkhty3"), tx.GetSndAddr())
assert.Equal(t, expectedAddr, tx.GetSndAddr())
assert.Equal(t, []byte(common.GenesisTxSignatureString), tx.GetSignature())
assert.Equal(t, uint64(0), tx.GetGasLimit())
assert.Equal(t, uint64(0), tx.GetGasPrice())
Expand Down Expand Up @@ -751,7 +754,8 @@ func TestAccountsParser_GenerateInitialTransactionsVerifyTxsHashes(t *testing.T)
func TestAccountsParser_GenesisMintingAddress(t *testing.T) {
t.Parallel()

ap := parsing.NewTestAccountsParser(createMockHexPubkeyConverter())
pkConv, _ := pubkeyConverter.NewBech32PubkeyConverter(32, "erd")
ap := parsing.NewTestAccountsParser(pkConv)
addr := ap.GenesisMintingAddress()
assert.Equal(t, hex.EncodeToString([]byte("erd17rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rcqqkhty3")), addr)
assert.Equal(t, "erd17rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rcqqkhty3", addr)
}
3 changes: 2 additions & 1 deletion genesis/parsing/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ func (ap *accountsParser) CreateMintTransaction(ia genesis.InitialAccountHandler
}

func NewTestAccountsParser(pubkeyConverter core.PubkeyConverter) *accountsParser {
addrBytes, _ := pubkeyConverter.Decode("erd17rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rcqqkhty3")
return &accountsParser{
pubkeyConverter: pubkeyConverter,
initialAccounts: make([]*data.InitialAccount, 0),
minterAddressBytes: []byte("erd17rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rc0pu8s7rcqqkhty3"),
minterAddressBytes: addrBytes,
keyGenerator: &mock.KeyGeneratorStub{},
hasher: &hashingMocks.HasherMock{},
marshalizer: &mock.MarshalizerMock{},
Expand Down
10 changes: 0 additions & 10 deletions genesis/process/genesisBlockCreator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,6 @@ func TestNewGenesisBlockCreator(t *testing.T) {
require.True(t, errors.Is(err, process.ErrNilGasSchedule))
require.Nil(t, gbc)
})
t.Run("nil GasSchedule should error", func(t *testing.T) {
t.Parallel()

arg := createMockArgument(t, "testdata/genesisTest1.json", &mock.InitialNodesHandlerStub{}, big.NewInt(22000))
arg.GasSchedule = nil

gbc, err := NewGenesisBlockCreator(arg)
require.True(t, errors.Is(err, process.ErrNilGasSchedule))
require.Nil(t, gbc)
})
t.Run("nil SmartContractParser should error", func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit b7e62c6

Please sign in to comment.