From 79adb9732779ab9271bc6b3e22207a48ce4f47b3 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 10 Jul 2017 16:11:40 +0200 Subject: [PATCH] accounts/keystore, consensus/ethash: fix tests when submodule is missing --- accounts/keystore/keystore_plain_test.go | 21 +++++++++++++++++---- appveyor.yml | 1 + consensus/ethash/consensus_test.go | 5 +++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/accounts/keystore/keystore_plain_test.go b/accounts/keystore/keystore_plain_test.go index 71a45cb01f..a1c3bc4b6c 100644 --- a/accounts/keystore/keystore_plain_test.go +++ b/accounts/keystore/keystore_plain_test.go @@ -22,6 +22,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "reflect" "strings" "testing" @@ -140,21 +141,32 @@ func TestV3_PBKDF2_1(t *testing.T) { testDecryptV3(tests["wikipage_test_vector_pbkdf2"], t) } +var testsSubmodule = filepath.Join("..", "..", "tests", "testdata", "KeyStoreTests") + +func skipIfSubmoduleMissing(t *testing.T) { + if !common.FileExist(testsSubmodule) { + t.Skipf("can't find JSON tests from submodule at %s", testsSubmodule) + } +} + func TestV3_PBKDF2_2(t *testing.T) { + skipIfSubmoduleMissing(t) t.Parallel() - tests := loadKeyStoreTestV3("../../tests/testdata/KeyStoreTests/basic_tests.json", t) + tests := loadKeyStoreTestV3(filepath.Join(testsSubmodule, "basic_tests.json"), t) testDecryptV3(tests["test1"], t) } func TestV3_PBKDF2_3(t *testing.T) { + skipIfSubmoduleMissing(t) t.Parallel() - tests := loadKeyStoreTestV3("../../tests/testdata/KeyStoreTests/basic_tests.json", t) + tests := loadKeyStoreTestV3(filepath.Join(testsSubmodule, "basic_tests.json"), t) testDecryptV3(tests["python_generated_test_with_odd_iv"], t) } func TestV3_PBKDF2_4(t *testing.T) { + skipIfSubmoduleMissing(t) t.Parallel() - tests := loadKeyStoreTestV3("../../tests/testdata/KeyStoreTests/basic_tests.json", t) + tests := loadKeyStoreTestV3(filepath.Join(testsSubmodule, "basic_tests.json"), t) testDecryptV3(tests["evilnonce"], t) } @@ -165,8 +177,9 @@ func TestV3_Scrypt_1(t *testing.T) { } func TestV3_Scrypt_2(t *testing.T) { + skipIfSubmoduleMissing(t) t.Parallel() - tests := loadKeyStoreTestV3("../../tests/testdata/KeyStoreTests/basic_tests.json", t) + tests := loadKeyStoreTestV3(filepath.Join(testsSubmodule, "basic_tests.json"), t) testDecryptV3(tests["test2"], t) } diff --git a/appveyor.yml b/appveyor.yml index 5bdcbc4862..945cafaf2e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,6 +21,7 @@ environment: PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH% install: + - git submodule update --init - rmdir C:\go /s /q - appveyor DownloadFile https://storage.googleapis.com/golang/go1.8.3.windows-%GETH_ARCH%.zip - 7z x go1.8.3.windows-%GETH_ARCH%.zip -y -oC:\ > NUL diff --git a/consensus/ethash/consensus_test.go b/consensus/ethash/consensus_test.go index d8f6b2b407..a58d220efa 100644 --- a/consensus/ethash/consensus_test.go +++ b/consensus/ethash/consensus_test.go @@ -20,6 +20,7 @@ import ( "encoding/json" "math/big" "os" + "path/filepath" "testing" "github.com/ethereum/go-ethereum/common/math" @@ -57,9 +58,9 @@ func (d *diffTest) UnmarshalJSON(b []byte) (err error) { } func TestCalcDifficulty(t *testing.T) { - file, err := os.Open("../../tests/testdata/BasicTests/difficulty.json") + file, err := os.Open(filepath.Join("..", "..", "tests", "testdata", "BasicTests", "difficulty.json")) if err != nil { - t.Fatal(err) + t.Skip(err) } defer file.Close()