Skip to content
Open
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
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Alicenet CI

on:
workflow_dispatch:
push:
branches: [ main, candidate ]
paths:
- "blockchain"
pull_request:
branches: [ main, candidate ]

Expand Down Expand Up @@ -202,4 +201,4 @@ jobs:
run: |
set -euo pipefail
./scripts/main.sh init 5
go test -v -timeout=45m ${{ matrix.test-cmd }}
go test -json -v -timeout=15m ${{ matrix.test-cmd }} 2>&1 | tee /tmp/gotest.log | gotestfmt
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ with [Madnet Wallet](https://github.com/MadBase/MadNetWallet-v2).

# TEST

### Verbose log
To show all the scripts logs in the console during tests you must set the env variable `ENABLE_SCRIPT_LOG` to `true`.
For instance to run blockchain tests you will execute
```shell
ENABLE_SCRIPT_LOG=true go test -v github.com/MadBase/MadNet/blockchain
```

### Random Kill and Restart

Randomly kill and restart the individual validators. There should be no noticeable change in the behavior of the other
Expand Down
55 changes: 35 additions & 20 deletions blockchain/dkg/dtest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ import (
"github.com/MadBase/MadNet/crypto/bn256/cloudflare"
)

type nullWriter struct{}

func (nullWriter) Write(p []byte) (n int, err error) { return len(p), nil }

func InitializeNewDetDkgStateInfo(n int) ([]*objects.DkgState, []*ecdsa.PrivateKey) {
return InitializeNewDkgStateInfo(n, true)
}
Expand Down Expand Up @@ -481,13 +485,12 @@ func StartHardHatNode(eth *blockchain.EthereumDetails) error {
fmt.Println("scriptPathJoined2: ", scriptPathJoined)

cmd := exec.Cmd{
Path: scriptPathJoined,
Args: []string{scriptPathJoined, "hardhat_node"},
Dir: filepath.Join(rootPath...),
Stdout: os.Stdout,
Stderr: os.Stderr,
Path: scriptPathJoined,
Args: []string{scriptPathJoined, "hardhat_node"},
Dir: filepath.Join(rootPath...),
}

setCommandStdOut(&cmd)
err := cmd.Start()

// if there is an error with our execution
Expand Down Expand Up @@ -525,6 +528,21 @@ func StartHardHatNode(eth *blockchain.EthereumDetails) error {
return nil
}

// setCommandStdOut If ENABLE_SCRIPT_LOG env variable is set as 'true' the command will show scripts logs
func setCommandStdOut(cmd *exec.Cmd) {

flagValue, found := os.LookupEnv("ENABLE_SCRIPT_LOG")
enabled, err := strconv.ParseBool(flagValue)

if err == nil && found && enabled {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = nullWriter{}
cmd.Stderr = nullWriter{}
}
}

func InitializeValidatorFiles(n int) error {

rootPath := GetMadnetRootPath()
Expand All @@ -534,13 +552,12 @@ func InitializeValidatorFiles(n int) error {
fmt.Println("scriptPathJoined2: ", scriptPathJoined)

cmd := exec.Cmd{
Path: scriptPathJoined,
Args: []string{scriptPathJoined, "init", strconv.Itoa(n)},
Dir: filepath.Join(rootPath...),
Stdout: os.Stdout,
Stderr: os.Stderr,
Path: scriptPathJoined,
Args: []string{scriptPathJoined, "init", strconv.Itoa(n)},
Dir: filepath.Join(rootPath...),
}

setCommandStdOut(&cmd)
err := cmd.Start()
if err != nil {
return fmt.Errorf("could not generate validator files: %s", err)
Expand All @@ -563,13 +580,12 @@ func StartDeployScripts(eth *blockchain.EthereumDetails, ctx context.Context) er
}

cmd := exec.Cmd{
Path: scriptPathJoined,
Args: []string{scriptPathJoined, "deploy"},
Dir: filepath.Join(rootPath...),
Stdout: os.Stdout,
Stderr: os.Stderr,
Path: scriptPathJoined,
Args: []string{scriptPathJoined, "deploy"},
Dir: filepath.Join(rootPath...),
}

setCommandStdOut(&cmd)
err = cmd.Run()

// if there is an error with our execution
Expand Down Expand Up @@ -658,13 +674,12 @@ func RegisterValidators(eth *blockchain.EthereumDetails, validatorAddresses []st
args = append(args, validatorAddresses...)

cmd := exec.Cmd{
Path: scriptPathJoined,
Args: args,
Dir: filepath.Join(rootPath...),
Stdout: os.Stdout,
Stderr: os.Stderr,
Path: scriptPathJoined,
Args: args,
Dir: filepath.Join(rootPath...),
}

setCommandStdOut(&cmd)
err := cmd.Run()

// if there is an error with our execution
Expand Down