2016-09-11 11:44:14 +00:00
|
|
|
package geth_test
|
|
|
|
|
|
|
|
import (
|
2016-09-15 03:08:06 +00:00
|
|
|
"os"
|
2016-10-07 14:48:36 +00:00
|
|
|
"path/filepath"
|
2016-09-11 11:44:14 +00:00
|
|
|
"testing"
|
2016-09-15 03:08:06 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/geth"
|
2016-09-11 11:44:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
testAddress = "0x89b50b2b26947ccad43accaef76c21d175ad85f4"
|
|
|
|
testAddressPassword = "asdf"
|
|
|
|
newAccountPassword = "badpassword"
|
2016-11-05 17:12:24 +00:00
|
|
|
testAddress1 = "0xf82da7547534045b4e00442bc89e16186cf8c272"
|
2016-09-11 11:44:14 +00:00
|
|
|
|
|
|
|
whisperMessage1 = "test message 1 (K1 -> K1)"
|
|
|
|
whisperMessage2 = "test message 2 (K1 -> '')"
|
|
|
|
whisperMessage3 = "test message 3 ('' -> '')"
|
|
|
|
whisperMessage4 = "test message 4 ('' -> K1)"
|
|
|
|
whisperMessage5 = "test message 5 (K2 -> K1)"
|
|
|
|
)
|
|
|
|
|
2016-09-15 03:08:06 +00:00
|
|
|
func TestMain(m *testing.M) {
|
2016-09-27 13:51:08 +00:00
|
|
|
syncRequired := false
|
2016-09-28 08:07:30 +00:00
|
|
|
if _, err := os.Stat(filepath.Join(geth.TestDataDir, "testnet")); os.IsNotExist(err) {
|
2016-09-27 13:51:08 +00:00
|
|
|
syncRequired = true
|
|
|
|
}
|
2016-09-15 03:08:06 +00:00
|
|
|
// make sure you panic if node start signal is not received
|
|
|
|
signalRecieved := make(chan struct{}, 1)
|
2016-10-13 18:02:48 +00:00
|
|
|
abortPanic := make(chan struct{}, 1)
|
2016-09-27 13:51:08 +00:00
|
|
|
if syncRequired {
|
|
|
|
geth.PanicAfter(geth.TestNodeSyncSeconds*time.Second, abortPanic, "TestNodeSetup")
|
|
|
|
} else {
|
|
|
|
geth.PanicAfter(10*time.Second, abortPanic, "TestNodeSetup")
|
|
|
|
}
|
2016-09-15 03:08:06 +00:00
|
|
|
|
|
|
|
geth.SetDefaultNodeNotificationHandler(func(jsonEvent string) {
|
|
|
|
if jsonEvent == `{"type":"node.started","event":{}}` {
|
|
|
|
signalRecieved <- struct{}{}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2016-09-11 11:44:14 +00:00
|
|
|
err := geth.PrepareTestNode()
|
|
|
|
if err != nil {
|
2016-09-15 03:08:06 +00:00
|
|
|
panic(err)
|
2016-09-11 11:44:14 +00:00
|
|
|
}
|
2016-09-15 03:08:06 +00:00
|
|
|
|
|
|
|
<-signalRecieved // block and wait for either panic or successful signal
|
2016-10-13 18:02:48 +00:00
|
|
|
abortPanic <- struct{}{}
|
2016-09-15 03:08:06 +00:00
|
|
|
|
|
|
|
os.Exit(m.Run())
|
2016-09-11 11:44:14 +00:00
|
|
|
}
|