mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
52 lines
1 KiB
Go
52 lines
1 KiB
Go
package chains
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestChain_ImportFromFile(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
type args struct {
|
|
filename string
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "ImportFromFile correct json file",
|
|
args: args{filename: "test_files/chain_test.json"},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "ImportFromFile correct legacy json file",
|
|
args: args{filename: "test_files/chain_legacy_test.json"},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "ImportFromFile wrong json file",
|
|
args: args{filename: "test_files/wrong_chain.json"},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "ImportFromFile nonexistent json file",
|
|
args: args{filename: "test_files/chain_test_nonexistent.json"},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := ImportFromFile(tt.args.filename)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("ImportFromFile() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
})
|
|
}
|
|
}
|