Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs fix and improvements to Node.Start() and Node.Stop() #414

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
23ff95d
Bug fix and improves to Node.Start() and Node.Stop()
hackintoshrao Nov 6, 2022
75d3460
Unit tests for the utility functions
hackintoshrao Nov 6, 2022
85480f5
Duplicating test utility functions
hackintoshrao Nov 6, 2022
fd9bcfb
Change test util names
hackintoshrao Nov 6, 2022
20e57e8
Updating test utility function names
hackintoshrao Nov 6, 2022
f0d4765
Moving GenerateTestConfig to cmd package
hackintoshrao Nov 8, 2022
3cd1c5f
Fixing Camel Casing
hackintoshrao Nov 8, 2022
fca24b3
Updating testconfig in blocksync tests
hackintoshrao Nov 8, 2022
51e2f0b
changing node status to custom type
hackintoshrao Nov 8, 2022
8289684
Tests for Node Status utility functions
hackintoshrao Nov 8, 2022
522f1e5
Simplifying node test assertions
hackintoshrao Nov 13, 2022
8158214
Fixing the typos in the comments
hackintoshrao Nov 13, 2022
95a477a
Fixing the glog messages
hackintoshrao Nov 13, 2022
716793a
Optimizing the usage of locks in cmd/node.go
hackintoshrao Nov 15, 2022
0cce354
Updating tests for cmd/node.go
hackintoshrao Nov 15, 2022
10c76ed
Renaming UpdateStatus to SetStatus
hackintoshrao Nov 15, 2022
062f84f
Minor changes
hackintoshrao Nov 25, 2022
b32370f
Deleting vs code settings file
hackintoshrao Nov 25, 2022
957c0d3
Suggested changes to pr 414 to reduce file changes
Nov 30, 2022
6e0c1ec
getTestDirectory -> getDirectory
Nov 30, 2022
ead4f3e
Merge pull request #1 from deso-protocol/ln/pr-414-suggested-changes
hackintoshrao Nov 30, 2022
967daa2
Renaming status functions
hackintoshrao Nov 30, 2022
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
60 changes: 58 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package cmd

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/deso-protocol/core/lib"
"github.com/golang/glog"
"github.com/spf13/viper"
"os"
"path/filepath"
"github.com/stretchr/testify/require"
)

// Global variable that determines the max tip blockheight of syncing nodes throughout test cases.
const MaxSyncBlockHeight = 1500

// Global variable that allows setting node configuration hypersync snapshot period.
const HyperSyncSnapshotPeriod = 1000

hackintoshrao marked this conversation as resolved.
Show resolved Hide resolved
type Config struct {
// Core
Params *lib.DeSoParams
Expand Down Expand Up @@ -220,3 +230,49 @@ func (config *Config) Print() {
glog.Infof("Rate Limit Feerate: %d", config.RateLimitFeerate)
glog.Infof("Min Feerate: %d", config.MinFeerate)
}

// GenerateTestConfig creates a default config for a node, with provided port, db directory, and number of max peers.
// It's usually the first step to starting a node.
func GenerateTestConfig(t *testing.T, port uint32, dataDir string, maxPeers uint32) Config {
config := Config{}
params := lib.DeSoMainnetParams

params.DNSSeeds = []string{}
config.Params = &params
config.ProtocolPort = uint16(port)
// "/Users/piotr/data_dirs/n98_1"
config.DataDirectory = dataDir
if err := os.MkdirAll(config.DataDirectory, os.ModePerm); err != nil {
t.Fatalf("Could not create data directories (%s): %v", config.DataDirectory, err)
}
config.TXIndex = false
config.HyperSync = false
config.MaxSyncBlockHeight = 0
config.ConnectIPs = []string{}
config.PrivateMode = true
config.GlogV = 0
config.GlogVmodule = "*bitcoin_manager*=0,*balance*=0,*view*=0,*frontend*=0,*peer*=0,*addr*=0,*network*=0,*utils*=0,*connection*=0,*main*=0,*server*=0,*mempool*=0,*miner*=0,*blockchain*=0"
config.MaxInboundPeers = maxPeers
config.TargetOutboundPeers = maxPeers
config.StallTimeoutSeconds = 900
config.MinFeerate = 1000
config.OneInboundPerIp = false
config.MaxBlockTemplatesCache = 100
config.MaxSyncBlockHeight = 100
config.MinBlockUpdateInterval = 10
config.SnapshotBlockHeightPeriod = HyperSyncSnapshotPeriod
config.MaxSyncBlockHeight = MaxSyncBlockHeight
config.SyncType = lib.NodeSyncTypeBlockSync
//config.ArchivalMode = true

return config
}

func getTestDirectory(t *testing.T, testName string) string {
hackintoshrao marked this conversation as resolved.
Show resolved Hide resolved
require := require.New(t)
dbDir, err := ioutil.TempDir("", testName)
if err != nil {
require.NoError(err)
}
return dbDir
}
Loading