Extended testGetDefaultConfig to support Rinkeby (#241)
This pull requests only extends testGetDefaultConfig to run against Rinkeby as well and fixes TestJailWhisper.
This commit is contained in:
parent
6a096607cf
commit
c85525e139
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
gethparams "github.com/ethereum/go-ethereum/params"
|
gethparams "github.com/ethereum/go-ethereum/params"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
"github.com/status-im/status-go/geth/common"
|
"github.com/status-im/status-go/geth/common"
|
||||||
"github.com/status-im/status-go/geth/node"
|
"github.com/status-im/status-go/geth/node"
|
||||||
"github.com/status-im/status-go/geth/params"
|
"github.com/status-im/status-go/geth/params"
|
||||||
|
@ -39,6 +40,9 @@ var nodeConfigJSON = `{
|
||||||
func testExportedAPI(t *testing.T, done chan struct{}) {
|
func testExportedAPI(t *testing.T, done chan struct{}) {
|
||||||
<-startTestNode(t)
|
<-startTestNode(t)
|
||||||
|
|
||||||
|
// FIXME(tiabc): All of that is done because usage of cgo is not supported in tests.
|
||||||
|
// Probably, there should be a cleaner way, for example, test cgo bindings in e2e tests
|
||||||
|
// separately from other internal tests.
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
fn func(t *testing.T) bool
|
fn func(t *testing.T) bool
|
||||||
|
@ -163,103 +167,34 @@ func testVerifyAccountPassword(t *testing.T) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetDefaultConfig(t *testing.T) bool {
|
func testGetDefaultConfig(t *testing.T) bool {
|
||||||
// test Mainnet config
|
networks := []struct {
|
||||||
nodeConfig := params.NodeConfig{}
|
chainID int
|
||||||
|
refChainConfig *gethparams.ChainConfig
|
||||||
|
}{
|
||||||
|
{params.MainNetworkID, gethparams.MainnetChainConfig},
|
||||||
|
{params.RopstenNetworkID, gethparams.TestnetChainConfig},
|
||||||
|
{params.RinkebyNetworkID, gethparams.RinkebyChainConfig},
|
||||||
|
}
|
||||||
|
for i := range networks {
|
||||||
|
network := networks[i]
|
||||||
|
|
||||||
rawResponse := GenerateConfig(C.CString("/tmp/data-folder"), 1, 1)
|
t.Run(fmt.Sprintf("networkID=%d", network.chainID), func(t *testing.T) {
|
||||||
if err := json.Unmarshal([]byte(C.GoString(rawResponse)), &nodeConfig); err != nil {
|
var (
|
||||||
t.Errorf("cannot decode response (%s): %v", C.GoString(rawResponse), err)
|
nodeConfig = params.NodeConfig{}
|
||||||
return false
|
rawResponse = GenerateConfig(C.CString("/tmp/data-folder"), C.int(network.chainID), 1)
|
||||||
}
|
)
|
||||||
|
if err := json.Unmarshal([]byte(C.GoString(rawResponse)), &nodeConfig); err != nil {
|
||||||
|
t.Errorf("cannot decode response (%s): %v", C.GoString(rawResponse), err)
|
||||||
|
}
|
||||||
|
|
||||||
genesis := new(core.Genesis)
|
genesis := new(core.Genesis)
|
||||||
if err := json.Unmarshal([]byte(nodeConfig.LightEthConfig.Genesis), genesis); err != nil {
|
if err := json.Unmarshal([]byte(nodeConfig.LightEthConfig.Genesis), genesis); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return false
|
}
|
||||||
}
|
|
||||||
chainConfig := genesis.Config
|
|
||||||
if chainConfig.HomesteadBlock.Cmp(gethparams.MainnetChainConfig.HomesteadBlock) != 0 {
|
|
||||||
t.Error("invalid chainConfig.HomesteadBlock")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.DAOForkBlock.Cmp(gethparams.MainnetChainConfig.DAOForkBlock) != 0 {
|
|
||||||
t.Error("invalid chainConfig.DAOForkBlock")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.DAOForkSupport != true {
|
|
||||||
t.Error("invalid chainConfig.DAOForkSupport")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP150Block.Cmp(gethparams.MainnetChainConfig.EIP150Block) != 0 {
|
|
||||||
t.Error("invalid chainConfig.EIP150Block")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP150Hash != gethparams.MainnetChainConfig.EIP150Hash {
|
|
||||||
t.Error("invalid chainConfig.EIP150Hash")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP155Block.Cmp(gethparams.MainnetChainConfig.EIP155Block) != 0 {
|
|
||||||
t.Error("invalid chainConfig.EIP155Block")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP158Block.Cmp(gethparams.MainnetChainConfig.EIP158Block) != 0 {
|
|
||||||
t.Error("invalid chainConfig.EIP158Block")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.ChainId.Cmp(gethparams.MainnetChainConfig.ChainId) != 0 {
|
|
||||||
t.Error("invalid chainConfig.ChainId")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// test Testnet
|
require.Equal(t, network.refChainConfig, genesis.Config)
|
||||||
nodeConfig = params.NodeConfig{}
|
})
|
||||||
rawResponse = GenerateConfig(C.CString("/tmp/data-folder"), 3, 1)
|
|
||||||
if err := json.Unmarshal([]byte(C.GoString(rawResponse)), &nodeConfig); err != nil {
|
|
||||||
t.Errorf("cannot decode response (%s): %v", C.GoString(rawResponse), err)
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
genesis = new(core.Genesis)
|
|
||||||
if err := json.Unmarshal([]byte(nodeConfig.LightEthConfig.Genesis), genesis); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
chainConfig = genesis.Config
|
|
||||||
refChainConfig := gethparams.TestnetChainConfig
|
|
||||||
|
|
||||||
if chainConfig.HomesteadBlock.Cmp(refChainConfig.HomesteadBlock) != 0 {
|
|
||||||
t.Error("invalid chainConfig.HomesteadBlock")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.DAOForkBlock != nil { // already forked
|
|
||||||
t.Error("invalid chainConfig.DAOForkBlock")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.DAOForkSupport != refChainConfig.DAOForkSupport {
|
|
||||||
t.Error("invalid chainConfig.DAOForkSupport")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP150Block.Cmp(refChainConfig.EIP150Block) != 0 {
|
|
||||||
t.Error("invalid chainConfig.EIP150Block")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP150Hash != refChainConfig.EIP150Hash {
|
|
||||||
t.Error("invalid chainConfig.EIP150Hash")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP155Block.Cmp(refChainConfig.EIP155Block) != 0 {
|
|
||||||
t.Error("invalid chainConfig.EIP155Block")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.EIP158Block.Cmp(refChainConfig.EIP158Block) != 0 {
|
|
||||||
t.Error("invalid chainConfig.EIP158Block")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if chainConfig.ChainId.Cmp(refChainConfig.ChainId) != 0 {
|
|
||||||
t.Error("invalid chainConfig.ChainId")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,18 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
whisperMessage1 = `test message 1 (K1 -> K2, signed+encrypted, from us)`
|
whisperMessage1 = `test message 1 (K1 -> K2, signed+encrypted, from us)`
|
||||||
whisperMessage2 = `test message 2 (K1 -> K1, signed+encrypted to ourselves)`
|
whisperMessage2 = `test message 3 (K1 -> "", signed broadcast)`
|
||||||
whisperMessage3 = `test message 3 (K1 -> "", signed broadcast)`
|
whisperMessage3 = `test message 4 ("" -> "", anon broadcast)`
|
||||||
whisperMessage4 = `test message 4 ("" -> "", anon broadcast)`
|
whisperMessage4 = `test message 5 ("" -> K1, encrypted anon broadcast)`
|
||||||
whisperMessage5 = `test message 5 ("" -> K1, encrypted anon broadcast)`
|
whisperMessage5 = `test message 6 (K2 -> K1, signed+encrypted, to us)`
|
||||||
whisperMessage6 = `test message 6 (K2 -> K1, signed+encrypted, to us)`
|
|
||||||
txSendFolder = "testdata/jail/tx-send/"
|
txSendFolder = "testdata/jail/tx-send/"
|
||||||
testChatID = "testChat"
|
testChatID = "testChat"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
baseStatusJSCode = string(static.MustAsset("testdata/jail/status.js"))
|
||||||
|
)
|
||||||
|
|
||||||
func (s *BackendTestSuite) TestJailSendQueuedTransaction() {
|
func (s *BackendTestSuite) TestJailSendQueuedTransaction() {
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
|
|
||||||
|
@ -276,6 +279,8 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
jailInstance := s.backend.JailManager()
|
jailInstance := s.backend.JailManager()
|
||||||
require.NotNil(jailInstance)
|
require.NotNil(jailInstance)
|
||||||
|
|
||||||
|
jailInstance.BaseJS(baseStatusJSCode)
|
||||||
|
|
||||||
whisperService := s.WhisperService()
|
whisperService := s.WhisperService()
|
||||||
whisperAPI := whisper.NewPublicWhisperAPI(whisperService)
|
whisperAPI := whisper.NewPublicWhisperAPI(whisperService)
|
||||||
|
|
||||||
|
@ -311,7 +316,6 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
whisperMessage3: false,
|
whisperMessage3: false,
|
||||||
whisperMessage4: false,
|
whisperMessage4: false,
|
||||||
whisperMessage5: false,
|
whisperMessage5: false,
|
||||||
whisperMessage6: false,
|
|
||||||
}
|
}
|
||||||
installedFilters := map[string]string{
|
installedFilters := map[string]string{
|
||||||
whisperMessage1: "",
|
whisperMessage1: "",
|
||||||
|
@ -319,7 +323,6 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
whisperMessage3: "",
|
whisperMessage3: "",
|
||||||
whisperMessage4: "",
|
whisperMessage4: "",
|
||||||
whisperMessage5: "",
|
whisperMessage5: "",
|
||||||
whisperMessage6: "",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
|
@ -330,7 +333,7 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
{
|
{
|
||||||
"test 0: ensure correct version of Whisper is used",
|
"test 0: ensure correct version of Whisper is used",
|
||||||
`
|
`
|
||||||
var expectedVersion = '0x5';
|
var expectedVersion = '5.0';
|
||||||
if (web3.version.whisper != expectedVersion) {
|
if (web3.version.whisper != expectedVersion) {
|
||||||
throw 'unexpected shh version, expected: ' + expectedVersion + ', got: ' + web3.version.whisper;
|
throw 'unexpected shh version, expected: ' + expectedVersion + ', got: ' + web3.version.whisper;
|
||||||
}
|
}
|
||||||
|
@ -341,41 +344,42 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
"test 1: encrypted signed message from us (From != nil && To != nil)",
|
"test 1: encrypted signed message from us (From != nil && To != nil)",
|
||||||
`
|
`
|
||||||
var identity1 = '` + accountKey1Hex + `';
|
var identity1 = '` + accountKey1Hex + `';
|
||||||
if (!web3.shh.hasKeyPair(identity1)) {
|
if (!shh.hasKeyPair(identity1)) {
|
||||||
throw 'idenitity "` + accountKey1Hex + `" not found in whisper';
|
throw 'idenitity "` + accountKey1Hex + `" not found in whisper';
|
||||||
}
|
}
|
||||||
|
|
||||||
var identity2 = '` + accountKey2Hex + `';
|
var identity2 = '` + accountKey2Hex + `';
|
||||||
if (!web3.shh.hasKeyPair(identity2)) {
|
if (!shh.hasKeyPair(identity2)) {
|
||||||
throw 'idenitity "` + accountKey2Hex + `" not found in whisper';
|
throw 'identitity "` + accountKey2Hex + `" not found in whisper';
|
||||||
}
|
}
|
||||||
|
|
||||||
var topic = makeTopic();
|
var topic = makeTopic();
|
||||||
var payload = '` + whisperMessage1 + `';
|
var payload = '` + whisperMessage1 + `';
|
||||||
|
|
||||||
// start watching for messages
|
// start watching for messages
|
||||||
var filter = shh.filter({
|
var filter = shh.newMessageFilter({
|
||||||
type: "asym",
|
|
||||||
sig: identity1,
|
sig: identity1,
|
||||||
key: identity2,
|
privateKeyID: identity2,
|
||||||
topics: [topic]
|
topics: [topic]
|
||||||
});
|
});
|
||||||
console.log(JSON.stringify(filter));
|
|
||||||
|
|
||||||
// post message
|
// post message
|
||||||
var message = {
|
var message = {
|
||||||
type: "asym",
|
|
||||||
sig: identity1,
|
|
||||||
key: identity2,
|
|
||||||
topic: topic,
|
|
||||||
payload: payload,
|
|
||||||
ttl: 20,
|
ttl: 20,
|
||||||
|
powTarget: 0.01,
|
||||||
|
powTime: 20,
|
||||||
|
topic: topic,
|
||||||
|
sig: identity1,
|
||||||
|
pubKey: identity2,
|
||||||
|
payload: web3.toHex(payload),
|
||||||
};
|
};
|
||||||
var err = shh.post(message)
|
|
||||||
if (err !== null) {
|
var sent = shh.post(message)
|
||||||
throw 'message not sent: ' + message;
|
if (!sent) {
|
||||||
|
throw 'message not sent: ' + JSON.stringify(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var filterName = '` + whisperMessage1 + `';
|
var filterName = '` + whisperMessage1 + `';
|
||||||
var filterId = filter.filterId;
|
var filterId = filter.filterId;
|
||||||
if (!filterId) {
|
if (!filterId) {
|
||||||
|
@ -385,36 +389,43 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test 2: encrypted signed message to yourself (From != nil && To != nil)",
|
"test 2: signed (known sender) broadcast (From != nil && To == nil)",
|
||||||
`
|
`
|
||||||
var identity = '` + accountKey1Hex + `';
|
var identity = '` + accountKey1Hex + `';
|
||||||
if (!web3.shh.hasKeyPair(identity)) {
|
if (!shh.hasKeyPair(identity)) {
|
||||||
throw 'idenitity "` + accountKey1Hex + `" not found in whisper';
|
throw 'idenitity "` + accountKey1Hex + `" not found in whisper';
|
||||||
}
|
}
|
||||||
|
|
||||||
var topic = makeTopic();
|
var topic = makeTopic();
|
||||||
var payload = '` + whisperMessage2 + `';
|
var payload = '` + whisperMessage2 + `';
|
||||||
|
|
||||||
|
// generate symmetric key
|
||||||
|
var keyid = shh.newSymKey();
|
||||||
|
if (!shh.hasSymKey(keyid)) {
|
||||||
|
throw new Error('key not found');
|
||||||
|
}
|
||||||
|
|
||||||
// start watching for messages
|
// start watching for messages
|
||||||
var filter = shh.filter({
|
var filter = shh.newMessageFilter({
|
||||||
type: "asym",
|
|
||||||
sig: identity,
|
sig: identity,
|
||||||
key: identity,
|
|
||||||
topics: [topic],
|
topics: [topic],
|
||||||
|
symKeyID: keyid
|
||||||
});
|
});
|
||||||
|
|
||||||
// post message
|
// post message
|
||||||
var message = {
|
var message = {
|
||||||
type: "asym",
|
ttl: 20,
|
||||||
sig: identity,
|
powTarget: 0.01,
|
||||||
key: identity,
|
powTime: 20,
|
||||||
topic: topic,
|
topic: topic,
|
||||||
payload: payload,
|
sig: identity,
|
||||||
ttl: 20,
|
symKeyID: keyid,
|
||||||
|
payload: web3.toHex(payload),
|
||||||
};
|
};
|
||||||
var err = shh.post(message)
|
|
||||||
if (err !== null) {
|
var sent = shh.post(message)
|
||||||
throw 'message not sent: ' + message;
|
if (!sent) {
|
||||||
|
throw 'message not sent: ' + JSON.stringify(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
var filterName = '` + whisperMessage2 + `';
|
var filterName = '` + whisperMessage2 + `';
|
||||||
|
@ -426,42 +437,36 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test 3: signed (known sender) broadcast (From != nil && To == nil)",
|
"test 3: anonymous broadcast (From == nil && To == nil)",
|
||||||
`
|
`
|
||||||
var identity = '` + accountKey1Hex + `';
|
|
||||||
if (!web3.shh.hasKeyPair(identity)) {
|
|
||||||
throw 'idenitity "` + accountKey1Hex + `" not found in whisper';
|
|
||||||
}
|
|
||||||
|
|
||||||
var topic = makeTopic();
|
var topic = makeTopic();
|
||||||
var payload = '` + whisperMessage3 + `';
|
var payload = '` + whisperMessage3 + `';
|
||||||
|
|
||||||
// generate symmetric key
|
// generate symmetric key
|
||||||
var keyid = shh.generateSymmetricKey();
|
var keyid = shh.newSymKey();
|
||||||
if (!shh.hasSymmetricKey(keyid)) {
|
if (!shh.hasSymKey(keyid)) {
|
||||||
throw new Error('key not found');
|
throw new Error('key not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// start watching for messages
|
// start watching for messages
|
||||||
var filter = shh.filter({
|
var filter = shh.newMessageFilter({
|
||||||
type: "sym",
|
|
||||||
sig: identity,
|
|
||||||
topics: [topic],
|
topics: [topic],
|
||||||
key: keyid
|
symKeyID: keyid
|
||||||
});
|
});
|
||||||
|
|
||||||
// post message
|
// post message
|
||||||
var message = {
|
var message = {
|
||||||
type: "sym",
|
|
||||||
sig: identity,
|
|
||||||
topic: topic,
|
|
||||||
payload: payload,
|
|
||||||
ttl: 20,
|
ttl: 20,
|
||||||
key: keyid
|
powTarget: 0.01,
|
||||||
|
powTime: 20,
|
||||||
|
topic: topic,
|
||||||
|
symKeyID: keyid,
|
||||||
|
payload: web3.toHex(payload),
|
||||||
};
|
};
|
||||||
var err = shh.post(message)
|
|
||||||
if (err !== null) {
|
var sent = shh.post(message)
|
||||||
throw 'message not sent: ' + message;
|
if (!sent) {
|
||||||
|
throw 'message not sent: ' + JSON.stringify(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
var filterName = '` + whisperMessage3 + `';
|
var filterName = '` + whisperMessage3 + `';
|
||||||
|
@ -473,35 +478,35 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test 4: anonymous broadcast (From == nil && To == nil)",
|
"test 4: encrypted anonymous message (From == nil && To != nil)",
|
||||||
`
|
`
|
||||||
|
var identity = '` + accountKey2Hex + `';
|
||||||
|
if (!shh.hasKeyPair(identity)) {
|
||||||
|
throw 'idenitity "` + accountKey2Hex + `" not found in whisper';
|
||||||
|
}
|
||||||
|
|
||||||
var topic = makeTopic();
|
var topic = makeTopic();
|
||||||
var payload = '` + whisperMessage4 + `';
|
var payload = '` + whisperMessage4 + `';
|
||||||
|
|
||||||
// generate symmetric key
|
|
||||||
var keyid = shh.generateSymmetricKey();
|
|
||||||
if (!shh.hasSymmetricKey(keyid)) {
|
|
||||||
throw new Error('key not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
// start watching for messages
|
// start watching for messages
|
||||||
var filter = shh.filter({
|
var filter = shh.newMessageFilter({
|
||||||
type: "sym",
|
privateKeyID: identity,
|
||||||
topics: [topic],
|
topics: [topic],
|
||||||
key: keyid
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// post message
|
// post message
|
||||||
var message = {
|
var message = {
|
||||||
type: "sym",
|
|
||||||
topic: topic,
|
|
||||||
payload: payload,
|
|
||||||
ttl: 20,
|
ttl: 20,
|
||||||
key: keyid
|
powTarget: 0.01,
|
||||||
|
powTime: 20,
|
||||||
|
topic: topic,
|
||||||
|
pubKey: identity,
|
||||||
|
payload: web3.toHex(payload),
|
||||||
};
|
};
|
||||||
var err = shh.post(message)
|
|
||||||
if (err !== null) {
|
var sent = shh.post(message)
|
||||||
throw 'message not sent: ' + err;
|
if (!sent) {
|
||||||
|
throw 'message not sent: ' + JSON.stringify(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
var filterName = '` + whisperMessage4 + `';
|
var filterName = '` + whisperMessage4 + `';
|
||||||
|
@ -513,83 +518,40 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test 5: encrypted anonymous message (From == nil && To != nil)",
|
"test 5: encrypted signed response to us (From != nil && To != nil)",
|
||||||
`
|
|
||||||
var identity = '` + accountKey2Hex + `';
|
|
||||||
if (!web3.shh.hasKeyPair(identity)) {
|
|
||||||
throw 'idenitity "` + accountKey2Hex + `" not found in whisper';
|
|
||||||
}
|
|
||||||
|
|
||||||
var topic = makeTopic();
|
|
||||||
var payload = '` + whisperMessage5 + `';
|
|
||||||
|
|
||||||
// start watching for messages
|
|
||||||
var filter = shh.filter({
|
|
||||||
type: "asym",
|
|
||||||
key: identity,
|
|
||||||
topics: [topic],
|
|
||||||
});
|
|
||||||
|
|
||||||
// post message
|
|
||||||
var message = {
|
|
||||||
type: "asym",
|
|
||||||
key: identity,
|
|
||||||
topic: topic,
|
|
||||||
payload: payload,
|
|
||||||
ttl: 20
|
|
||||||
};
|
|
||||||
var err = shh.post(message)
|
|
||||||
if (err !== null) {
|
|
||||||
throw 'message not sent: ' + message;
|
|
||||||
}
|
|
||||||
|
|
||||||
var filterName = '` + whisperMessage5 + `';
|
|
||||||
var filterId = filter.filterId;
|
|
||||||
if (!filterId) {
|
|
||||||
throw 'filter not installed properly';
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"test 6: encrypted signed response to us (From != nil && To != nil)",
|
|
||||||
`
|
`
|
||||||
var identity1 = '` + accountKey1Hex + `';
|
var identity1 = '` + accountKey1Hex + `';
|
||||||
if (!web3.shh.hasKeyPair(identity1)) {
|
if (!shh.hasKeyPair(identity1)) {
|
||||||
throw 'idenitity "` + accountKey1Hex + `" not found in whisper';
|
throw 'idenitity "` + accountKey1Hex + `" not found in whisper';
|
||||||
}
|
}
|
||||||
|
|
||||||
var identity2 = '` + accountKey2Hex + `';
|
var identity2 = '` + accountKey2Hex + `';
|
||||||
if (!web3.shh.hasKeyPair(identity2)) {
|
if (!shh.hasKeyPair(identity2)) {
|
||||||
throw 'idenitity "` + accountKey2Hex + `" not found in whisper';
|
throw 'idenitity "` + accountKey2Hex + `" not found in whisper';
|
||||||
}
|
}
|
||||||
|
|
||||||
var topic = makeTopic();
|
var topic = makeTopic();
|
||||||
var payload = '` + whisperMessage6 + `';
|
var payload = '` + whisperMessage5 + `';
|
||||||
|
|
||||||
// start watching for messages
|
// start watching for messages
|
||||||
var filter = shh.filter({
|
var filter = shh.newMessageFilter({
|
||||||
type: "asym",
|
privateKeyID: identity1,
|
||||||
sig: identity2,
|
sig: identity2,
|
||||||
key: identity1,
|
topics: [topic],
|
||||||
topics: [topic]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// post message
|
// post message
|
||||||
var message = {
|
var message = {
|
||||||
type: "asym",
|
|
||||||
sig: identity2,
|
sig: identity2,
|
||||||
key: identity1,
|
pubKey: identity1,
|
||||||
topic: topic,
|
topic: topic,
|
||||||
payload: payload,
|
payload: web3.toHex(payload),
|
||||||
ttl: 20
|
ttl: 20,
|
||||||
|
powTime: 20,
|
||||||
|
powTarget: 0.01,
|
||||||
};
|
};
|
||||||
var err = shh.post(message)
|
var sent = shh.post(message)
|
||||||
if (err !== null) {
|
if (!sent) {
|
||||||
throw 'message not sent: ' + message;
|
throw 'message not sent: ' + message;
|
||||||
}
|
}
|
||||||
|
var filterName = '` + whisperMessage5 + `';
|
||||||
var filterName = '` + whisperMessage6 + `';
|
|
||||||
var filterId = filter.filterId;
|
var filterId = filter.filterId;
|
||||||
if (!filterId) {
|
if (!filterId) {
|
||||||
throw 'filter not installed properly';
|
throw 'filter not installed properly';
|
||||||
|
@ -602,6 +564,7 @@ func (s *BackendTestSuite) TestJailWhisper() {
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
s.T().Log(testCase.name)
|
s.T().Log(testCase.name)
|
||||||
testCaseKey := crypto.Keccak256Hash([]byte(testCase.name)).Hex()
|
testCaseKey := crypto.Keccak256Hash([]byte(testCase.name)).Hex()
|
||||||
|
|
||||||
jailInstance.Parse(testCaseKey, `
|
jailInstance.Parse(testCaseKey, `
|
||||||
var shh = web3.shh;
|
var shh = web3.shh;
|
||||||
var makeTopic = function () {
|
var makeTopic = function () {
|
||||||
|
@ -718,7 +681,8 @@ func (s *BackendTestSuite) TestJailVMPersistence() {
|
||||||
}
|
}
|
||||||
|
|
||||||
jailInstance := s.backend.JailManager()
|
jailInstance := s.backend.JailManager()
|
||||||
jailInstance.BaseJS(string(static.MustAsset("testdata/jail/status.js")))
|
jailInstance.BaseJS(baseStatusJSCode)
|
||||||
|
|
||||||
parseResult := jailInstance.Parse(testChatID, `
|
parseResult := jailInstance.Parse(testChatID, `
|
||||||
var total = 0;
|
var total = 0;
|
||||||
_status_catalog['ping'] = function(params) {
|
_status_catalog['ping'] = function(params) {
|
||||||
|
|
|
@ -620,7 +620,7 @@ func (s *BackendTestSuite) TestEvictionOfQueuedTransactions() {
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
go s.backend.SendTransaction(nil, common.SendTxArgs{}) // nolint: errcheck
|
go s.backend.SendTransaction(nil, common.SendTxArgs{}) // nolint: errcheck
|
||||||
}
|
}
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(2 * time.Second) // FIXME(tiabc): more reliable synchronization to ensure all transactions are enqueued
|
||||||
|
|
||||||
log.Info(fmt.Sprintf("Number of transactions queued: %d. Queue size (shouldn't be more than %d): %d",
|
log.Info(fmt.Sprintf("Number of transactions queued: %d. Queue size (shouldn't be more than %d): %d",
|
||||||
i, node.DefaultTxQueueCap, txQueue.Count()))
|
i, node.DefaultTxQueueCap, txQueue.Count()))
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package testing implements the base level testing types needed.
|
||||||
package testing
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -6,6 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -136,13 +138,20 @@ func FirstBlockHash(require *assertions.Assertions, nodeManager common.NodeManag
|
||||||
// MakeTestNodeConfig defines a function to return a giving params.NodeConfig
|
// MakeTestNodeConfig defines a function to return a giving params.NodeConfig
|
||||||
// where specific network addresses are assigned based on provieded network id.
|
// where specific network addresses are assigned based on provieded network id.
|
||||||
func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
|
func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
|
||||||
|
testDir := filepath.Join(TestDataDir, TestNetworkNames[networkID])
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
testDir = filepath.ToSlash(testDir)
|
||||||
|
}
|
||||||
|
|
||||||
configJSON := `{
|
configJSON := `{
|
||||||
"NetworkId": ` + strconv.Itoa(networkID) + `,
|
"NetworkId": ` + strconv.Itoa(networkID) + `,
|
||||||
"DataDir": "` + filepath.Join(TestDataDir, TestNetworkNames[networkID]) + `",
|
"DataDir": "` + testDir + `",
|
||||||
"HTTPPort": ` + strconv.Itoa(TestConfig.Node.HTTPPort) + `,
|
"HTTPPort": ` + strconv.Itoa(TestConfig.Node.HTTPPort) + `,
|
||||||
"WSPort": ` + strconv.Itoa(TestConfig.Node.WSPort) + `,
|
"WSPort": ` + strconv.Itoa(TestConfig.Node.WSPort) + `,
|
||||||
"LogLevel": "INFO"
|
"LogLevel": "INFO"
|
||||||
}`
|
}`
|
||||||
|
|
||||||
nodeConfig, err := params.LoadNodeConfig(configJSON)
|
nodeConfig, err := params.LoadNodeConfig(configJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
16
package.json
16
package.json
|
@ -1,26 +1,26 @@
|
||||||
{
|
{
|
||||||
"name": "status-go",
|
"name": "status-js",
|
||||||
"version": "0.9.6",
|
"version": "0.9.8",
|
||||||
"description": "JavaScript tests for RPC API (Whisper/5, Swarm)",
|
"description": "JavaScript tests for RPC API (Whisper/5, Swarm)",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"mocha": "^3.3.0",
|
"mocha": "^3.5.0",
|
||||||
"requirejs": "^2.3.3",
|
"requirejs": "^2.3.4",
|
||||||
"web3": "github:farazdagi/web3.js#geth/1.6.1-unstable"
|
"web3": "https://github.com/status-im/web3.js#status-develop"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --bail --slow 1000 --full-trace static/tests"
|
"test": "mocha --bail --slow 1000 --full-trace static/tests"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/farazdagi/status-go.git"
|
"url": "git+https://github.com/status-im/status-go.git"
|
||||||
},
|
},
|
||||||
"author": "Victor Farazdagi",
|
"author": "Victor Farazdagi",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/farazdagi/status-go/issues"
|
"url": "https://github.com/status-im/status-go/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/farazdagi/status-go#readme"
|
"homepage": "https://github.com/status-im/status-go#readme"
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue