2019-05-16 08:25:32 -07:00
package genutil
2019-02-08 13:45:41 -08:00
import (
"encoding/json"
2020-12-08 09:22:43 -08:00
"os"
2019-02-08 13:45:41 -08:00
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/require"
2020-12-08 09:22:43 -08:00
"github.com/tendermint/tendermint/config"
2019-02-08 13:45:41 -08:00
)
func TestExportGenesisFileWithTime ( t * testing . T ) {
t . Parallel ( )
2020-09-18 04:08:24 -07:00
fname := filepath . Join ( t . TempDir ( ) , "genesis.json" )
2020-08-14 10:58:53 -07:00
require . NoError ( t , ExportGenesisFileWithTime ( fname , "test" , nil , json . RawMessage ( ` { "account_owner": "Bob"} ` ) , time . Now ( ) ) )
2019-02-08 13:45:41 -08:00
}
2020-12-08 09:22:43 -08:00
func TestInitializeNodeValidatorFilesFromMnemonic ( t * testing . T ) {
t . Parallel ( )
cfg := config . TestConfig ( )
cfg . RootDir = t . TempDir ( )
require . NoError ( t , os . MkdirAll ( filepath . Join ( cfg . RootDir , "config" ) , 0755 ) )
tests := [ ] struct {
name string
mnemonic string
expError bool
} {
{
name : "invalid mnemonic returns error" ,
mnemonic : "side video kiss hotel essence" ,
expError : true ,
} ,
{
name : "empty mnemonic does not return error" ,
mnemonic : "" ,
expError : false ,
} ,
{
name : "valid mnemonic does not return error" ,
mnemonic : "side video kiss hotel essence door angle student degree during vague adjust submit trick globe muscle frozen vacuum artwork million shield bind useful wave" ,
expError : false ,
} ,
}
for _ , tt := range tests {
tt := tt
t . Run ( tt . name , func ( t * testing . T ) {
_ , _ , err := InitializeNodeValidatorFilesFromMnemonic ( cfg , tt . mnemonic )
if tt . expError {
require . Error ( t , err )
} else {
require . NoError ( t , err )
}
} )
}
}