mirror of
https://github.com/status-im/status-go.git
synced 2025-02-02 09:56:52 +00:00
6cdea4ef97
* Update project to use Whisper v6. Part of #638 * Revert "Add patch to downgrade usage of Whisper v6 to v5 in some geth 1.8.1 vendor files. Part of #665" - this reverts commit 6aefb4c8fd02dbcfffac6b69e8bb22b13ef86b6b. * Enable light mode on Whisper v6 for non-mail servers. Part of #638 * Fix race condition in whisperv6/peer.go. Part of #665 (PR already accepted upstream for 1.8.2) * Update bootnode addresses in staticnodes.json. Part of #638 * Add `shh.lightclient` flag and tests for bloom filter setting logic. Part of #638 * Move MakeTestNodeConfig to utils. Part of #638 * Reduce PoW in `whisper_jail_test.go` to fix flaky test. Part of #638
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package e2e
|
|
|
|
import (
|
|
"context"
|
|
|
|
gethcommon "github.com/ethereum/go-ethereum/common"
|
|
"github.com/status-im/status-go/geth/common"
|
|
"github.com/status-im/status-go/geth/params"
|
|
)
|
|
|
|
// TestNodeOption is a callback passed to StartTestNode which alters its config.
|
|
type TestNodeOption func(config *params.NodeConfig)
|
|
|
|
// WithUpstream returns TestNodeOption which enabled UpstreamConfig.
|
|
func WithUpstream(url string) TestNodeOption {
|
|
return func(config *params.NodeConfig) {
|
|
config.UpstreamConfig.Enabled = true
|
|
config.UpstreamConfig.URL = url
|
|
}
|
|
}
|
|
|
|
// WithDataDir returns TestNodeOption that allows to set another data dir.
|
|
func WithDataDir(path string) TestNodeOption {
|
|
return func(config *params.NodeConfig) {
|
|
config.DataDir = path
|
|
}
|
|
}
|
|
|
|
// FirstBlockHash validates Attach operation for the NodeManager.
|
|
func FirstBlockHash(nodeManager common.NodeManager) (string, error) {
|
|
// obtain RPC client for running node
|
|
runningNode, err := nodeManager.Node()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
rpcClient, err := runningNode.Attach()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
// get first block
|
|
var firstBlock struct {
|
|
Hash gethcommon.Hash `json:"hash"`
|
|
}
|
|
|
|
err = rpcClient.CallContext(context.Background(), &firstBlock, "eth_getBlockByNumber", "0x0", true)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return firstBlock.Hash.Hex(), nil
|
|
}
|