Skip to content

Commit

Permalink
feat: mock SL doesn't use keyring path from config. (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Jun 22, 2023
1 parent d31da1a commit 5abf3ca
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
12 changes: 7 additions & 5 deletions config/defaults.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"path/filepath"
"time"

"github.com/dymensionxyz/dymint/settlement"
Expand All @@ -12,7 +13,7 @@ const (
// Version is a default dymint version for P2P client.
Version = "0.2.2"

DefaultHomeDir = ".dymint"
DefaultHomeDir = "sequencer_keys"
DefaultChainID = "dymint-testnet"
)

Expand All @@ -28,8 +29,8 @@ func DefaultConfig(home, chainId string) *NodeConfig {
Aggregator: true,
BlockManagerConfig: BlockManagerConfig{
BlockTime: 200 * time.Millisecond,
EmptyBlocksMaxTime: 60 * time.Second,
BatchSubmitMaxTime: 600 * time.Second,
EmptyBlocksMaxTime: 3 * time.Second,
BatchSubmitMaxTime: 20 * time.Second,
NamespaceID: "000000000000ffff",
BlockBatchSize: 500,
BlockBatchSizeBytes: 1500000},
Expand All @@ -38,8 +39,9 @@ func DefaultConfig(home, chainId string) *NodeConfig {
}

if home == "" {
home = DefaultHomeDir
home = "/tmp"
}
keyringDir := filepath.Join(home, DefaultHomeDir)
if chainId == "" {
chainId = DefaultChainID
}
Expand All @@ -48,7 +50,7 @@ func DefaultConfig(home, chainId string) *NodeConfig {
KeyringBackend: "test",
NodeAddress: "http://127.0.0.1:36657",
RollappID: chainId,
KeyringHomeDir: home,
KeyringHomeDir: keyringDir,
DymAccountName: "sequencer",
GasPrices: "0.025udym",
}
Expand Down
8 changes: 6 additions & 2 deletions node/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package node
import (
"context"
"crypto/rand"
"encoding/hex"
mrand "math/rand"
"testing"
"time"
Expand Down Expand Up @@ -38,7 +39,10 @@ func TestAggregatorMode(t *testing.T) {
app.On("Info", mock.Anything).Return(abci.ResponseInfo{LastBlockHeight: 0, LastBlockAppHash: []byte{0}})

key, _, _ := crypto.GenerateEd25519Key(rand.Reader)
signingKey, _, _ := crypto.GenerateEd25519Key(rand.Reader)
signingKey, pubkey, _ := crypto.GenerateEd25519Key(rand.Reader)
pubkeyBytes, _ := pubkey.Raw()
proposerKey := hex.EncodeToString(pubkeyBytes)

anotherKey, _, _ := crypto.GenerateEd25519Key(rand.Reader)

blockManagerConfig := config.BlockManagerConfig{
Expand All @@ -57,7 +61,7 @@ func TestAggregatorMode(t *testing.T) {
DALayer: "mock",
DAConfig: "",
SettlementLayer: "mock",
SettlementConfig: settlement.Config{},
SettlementConfig: settlement.Config{ProposerPubKey: proposerKey},
}
node, err := NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
require.NoError(err)
Expand Down
3 changes: 3 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func NewNode(ctx context.Context, conf config.NodeConfig, p2pKey crypto.PrivKey,
if settlementlc == nil {
return nil, fmt.Errorf("couldn't get settlement client named '%s'", conf.SettlementLayer)
}
if conf.SettlementLayer == "mock" {
conf.SettlementConfig.KeyringHomeDir = conf.RootDir
}
err = settlementlc.Init(conf.SettlementConfig, pubsubServer, logger.With("module", "settlement_client"))
if err != nil {
return nil, fmt.Errorf("settlement layer client initialization error: %w", err)
Expand Down
6 changes: 4 additions & 2 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,9 @@ func getRPC(t *testing.T) (*mocks.Application, *Client) {
app := &mocks.Application{}
app.On("InitChain", mock.Anything).Return(abci.ResponseInitChain{})
key, _, _ := crypto.GenerateEd25519Key(crand.Reader)
signingKey, _, err := crypto.GenerateEd25519Key(crand.Reader)
signingKey, pubkey, err := crypto.GenerateEd25519Key(crand.Reader)
pubkeyBytes, _ := pubkey.Raw()
proposerKey := hex.EncodeToString(pubkeyBytes)
require.NoError(err)

config := config.NodeConfig{
Expand All @@ -808,7 +810,7 @@ func getRPC(t *testing.T) (*mocks.Application, *Client) {
DALayer: "mock",
DAConfig: "",
SettlementLayer: "mock",
SettlementConfig: settlement.Config{},
SettlementConfig: settlement.Config{ProposerPubKey: proposerKey},
}
node, err := node.NewNode(context.Background(), config, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger())
require.NoError(err)
Expand Down

0 comments on commit 5abf3ca

Please sign in to comment.