Skip to content

Commit

Permalink
Upgrade geth to 1.9.5 and Whisper (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Babik authored Oct 4, 2019
1 parent 40e66e6 commit 26880b8
Show file tree
Hide file tree
Showing 1,154 changed files with 102,268 additions and 30,147 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ run:
- bindata.go
- .*_mock.go
- jail/doc.go
- contracts/

output:
format: colored-line-number
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ BUILD_FLAGS ?= $(shell echo "-ldflags '\
-X github.com/status-im/status-go/params.Version=$(RELEASE_TAG) \
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT) \
-X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=$(ENABLE_METRICS)'")
BUILD_FLAGS_MOBILE ?= $(shell echo "-ldflags '\
-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` \
-X github.com/status-im/status-go/params.Version=$(RELEASE_TAG) \
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT)'")

networkid ?= StatusChain
gotest_extraflags =
Expand Down Expand Up @@ -92,13 +96,13 @@ statusgo-cross: statusgo-android statusgo-ios
statusgo-android: ##@cross-compile Build status-go for Android
@echo "Building status-go for Android..."
gomobile init
gomobile bind -target=android -ldflags="-s -w" $(BUILD_FLAGS) -o build/bin/statusgo.aar github.com/status-im/status-go/mobile
gomobile bind -target=android -ldflags="-s -w" $(BUILD_FLAGS_MOBILE) -o build/bin/statusgo.aar github.com/status-im/status-go/mobile
@echo "Android cross compilation done in build/bin/statusgo.aar"

statusgo-ios: ##@cross-compile Build status-go for iOS
@echo "Building status-go for iOS..."
gomobile init
gomobile bind -v -target=ios -ldflags="-s -w" $(BUILD_FLAGS) -o build/bin/Statusgo.framework github.com/status-im/status-go/mobile
gomobile bind -v -target=ios -ldflags="-s -w" $(BUILD_FLAGS_MOBILE) -o build/bin/Statusgo.framework github.com/status-im/status-go/mobile
@echo "iOS framework cross compilation done in build/bin/Statusgo.framework"

statusgo-xgo: xgo-install ##@cross-compile Build status-go for xgo targets
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.33.0-beta.1
0.34.0-beta.0
39 changes: 21 additions & 18 deletions account/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"reflect"
"testing"

"github.com/status-im/status-go/t/utils"

"github.com/ethereum/go-ethereum/common"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand All @@ -28,10 +29,11 @@ func TestVerifyAccountPassword(t *testing.T) {
defer os.RemoveAll(emptyKeyStoreDir) //nolint: errcheck

// import account keys
require.NoError(t, ImportTestAccount(keyStoreDir, GetAccount1PKFile()))
require.NoError(t, ImportTestAccount(keyStoreDir, GetAccount2PKFile()))
utils.Init()
require.NoError(t, utils.ImportTestAccount(keyStoreDir, utils.GetAccount1PKFile()))
require.NoError(t, utils.ImportTestAccount(keyStoreDir, utils.GetAccount2PKFile()))

account1Address := gethcommon.BytesToAddress(gethcommon.FromHex(TestConfig.Account1.WalletAddress))
account1Address := gethcommon.BytesToAddress(gethcommon.FromHex(utils.TestConfig.Account1.WalletAddress))

testCases := []struct {
name string
Expand All @@ -43,37 +45,37 @@ func TestVerifyAccountPassword(t *testing.T) {
{
"correct address, correct password (decrypt should succeed)",
keyStoreDir,
TestConfig.Account1.WalletAddress,
TestConfig.Account1.Password,
utils.TestConfig.Account1.WalletAddress,
utils.TestConfig.Account1.Password,
nil,
},
{
"correct address, correct password, non-existent key store",
filepath.Join(keyStoreDir, "non-existent-folder"),
TestConfig.Account1.WalletAddress,
TestConfig.Account1.Password,
utils.TestConfig.Account1.WalletAddress,
utils.TestConfig.Account1.Password,
fmt.Errorf("cannot traverse key store folder: lstat %s/non-existent-folder: no such file or directory", keyStoreDir),
},
{
"correct address, correct password, empty key store (pk is not there)",
emptyKeyStoreDir,
TestConfig.Account1.WalletAddress,
TestConfig.Account1.Password,
utils.TestConfig.Account1.WalletAddress,
utils.TestConfig.Account1.Password,
fmt.Errorf("cannot locate account for address: %s", account1Address.Hex()),
},
{
"wrong address, correct password",
keyStoreDir,
"0x79791d3e8f2daa1f7fec29649d152c0ada3cc535",
TestConfig.Account1.Password,
utils.TestConfig.Account1.Password,
fmt.Errorf("cannot locate account for address: %s", "0x79791d3E8F2dAa1F7FeC29649d152c0aDA3cc535"),
},
{
"correct address, wrong password",
keyStoreDir,
TestConfig.Account1.WalletAddress,
utils.TestConfig.Account1.WalletAddress,
"wrong password", // wrong password
errors.New("could not decrypt key with given passphrase"),
errors.New("could not decrypt key with given password"),
},
}
for _, testCase := range testCases {
Expand Down Expand Up @@ -101,13 +103,14 @@ func TestVerifyAccountPasswordWithAccountBeforeEIP55(t *testing.T) {
defer os.RemoveAll(keyStoreDir) //nolint: errcheck

// Import keys and make sure one was created before EIP55 introduction.
err = ImportTestAccount(keyStoreDir, "test-account3-before-eip55.pk")
utils.Init()
err = utils.ImportTestAccount(keyStoreDir, "test-account3-before-eip55.pk")
require.NoError(t, err)

accManager := NewManager()

address := gethcommon.HexToAddress(TestConfig.Account3.WalletAddress)
_, err = accManager.VerifyAccountPassword(keyStoreDir, address.Hex(), TestConfig.Account3.Password)
address := gethcommon.HexToAddress(utils.TestConfig.Account3.WalletAddress)
_, err = accManager.VerifyAccountPassword(keyStoreDir, address.Hex(), utils.TestConfig.Account3.Password)
require.NoError(t, err)
}

Expand Down Expand Up @@ -226,7 +229,7 @@ func (s *ManagerTestSuite) TestSelectAccountWrongAddress() {
}

func (s *ManagerTestSuite) TestSelectAccountWrongPassword() {
s.testSelectAccount(common.HexToAddress(s.testAccount.chatAddress), common.HexToAddress(s.testAccount.walletAddress), "wrong", errors.New("cannot retrieve a valid key for a given account: could not decrypt key with given passphrase"))
s.testSelectAccount(common.HexToAddress(s.testAccount.chatAddress), common.HexToAddress(s.testAccount.walletAddress), "wrong", errors.New("cannot retrieve a valid key for a given account: could not decrypt key with given password"))
}

func (s *ManagerTestSuite) testSelectAccount(chat, wallet common.Address, password string, expErr error) {
Expand Down Expand Up @@ -314,7 +317,7 @@ func (s *ManagerTestSuite) TestAddressToDecryptedAccountWrongAddress() {
}

func (s *ManagerTestSuite) TestAddressToDecryptedAccountWrongPassword() {
s.testAddressToDecryptedAccount(s.walletAddress, "wrong", errors.New("cannot retrieve a valid key for a given account: could not decrypt key with given passphrase"))
s.testAddressToDecryptedAccount(s.walletAddress, "wrong", errors.New("cannot retrieve a valid key for a given account: could not decrypt key with given password"))
}

func (s *ManagerTestSuite) testAddressToDecryptedAccount(wallet, password string, expErr error) {
Expand Down
3 changes: 2 additions & 1 deletion account/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ func makeAccountManager(keydir string) (manager *accounts.Manager, err error) {
if err := os.MkdirAll(keydir, 0700); err != nil {
return nil, err
}
return accounts.NewManager(keystore.NewKeyStore(keydir, keystore.LightScryptN, keystore.LightScryptP)), nil
config := accounts.Config{InsecureUnlockAllowed: false}
return accounts.NewManager(&config, keystore.NewKeyStore(keydir, keystore.LightScryptN, keystore.LightScryptP)), nil
}
2 changes: 2 additions & 0 deletions api/backend_subs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ func createSubscription(t *testing.T, backend *StatusBackend, params string) str
}

func initNodeAndLogin(t *testing.T, backend *StatusBackend) (string, string) {
utils.Init()

config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)

Expand Down
26 changes: 25 additions & 1 deletion api/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
)

func TestBackendStartNodeConcurrently(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -61,6 +63,8 @@ func TestBackendStartNodeConcurrently(t *testing.T) {
}

func TestBackendRestartNodeConcurrently(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand All @@ -87,6 +91,8 @@ func TestBackendRestartNodeConcurrently(t *testing.T) {
// TODO(adam): add concurrent tests for ResetChainData()

func TestBackendGettersConcurrently(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -139,6 +145,8 @@ func TestBackendGettersConcurrently(t *testing.T) {
}

func TestBackendAccountsConcurrently(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -199,6 +207,8 @@ func TestBackendAccountsConcurrently(t *testing.T) {
}

func TestBackendInjectChatAccount(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -273,6 +283,8 @@ func TestBackendConnectionChangesToOffline(t *testing.T) {
}

func TestBackendCallRPCConcurrently(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -347,6 +359,8 @@ func TestAppStateChange(t *testing.T) {
}

func TestBlockedRPCMethods(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -385,6 +399,8 @@ func TestCallRPCWithStoppedNode(t *testing.T) {
// TODO(adam): add concurrent tests for: SendTransaction

func TestStartStopMultipleTimes(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand All @@ -402,6 +418,8 @@ func TestStartStopMultipleTimes(t *testing.T) {
}

func TestSignHash(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -440,6 +458,8 @@ func TestSignHash(t *testing.T) {
}

func TestHashTypedData(t *testing.T) {
utils.Init()

backend := NewStatusBackend()
config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID)
require.NoError(t, err)
Expand Down Expand Up @@ -486,6 +506,8 @@ func TestHashTypedData(t *testing.T) {
}

func TestBackendGetVerifiedAccount(t *testing.T) {
utils.Init()

password := "test"
tmpdir, err := ioutil.TempDir("", "verified-account-test-")
require.NoError(t, err)
Expand Down Expand Up @@ -520,7 +542,7 @@ func TestBackendGetVerifiedAccount(t *testing.T) {
require.NoError(t, err)
require.NoError(t, db.SaveAccounts([]accounts.Account{{Address: address}}))
key, err := backend.getVerifiedWalletAccount(address.String(), "wrong-password")
require.EqualError(t, err, "could not decrypt key with given passphrase")
require.EqualError(t, err, "could not decrypt key with given password")
require.Nil(t, key)
})

Expand All @@ -539,6 +561,8 @@ func TestBackendGetVerifiedAccount(t *testing.T) {
}

func TestLoginWithKey(t *testing.T) {
utils.Init()

b := NewStatusBackend()
pkey, err := crypto.GenerateKey()
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/statusd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ var logger = log.New("package", "status-go/cmd/statusd")

func init() {
flag.Var(&configFiles, "c", "JSON configuration file(s). Multiple configuration files can be specified, and will be merged in occurrence order")
}

// nolint:gocyclo
func main() {
colors := terminal.IsTerminal(int(os.Stdin.Fd()))
if err := logutils.OverrideRootLog(true, "ERROR", logutils.FileOptions{}, colors); err != nil {
stdlog.Fatalf("Error initializing logger: %v", err)
Expand All @@ -78,10 +81,7 @@ func init() {
logger.Error("Extra args in command line: %v", flag.Args())
os.Exit(1)
}
}

// nolint:gocyclo
func main() {
opts := []params.Option{params.WithFleet(params.FleetBeta)}
if *mailserver {
opts = append(opts, params.WithMailserver())
Expand Down Expand Up @@ -275,7 +275,7 @@ Examples:
Options:
`
fmt.Fprintf(os.Stderr, usage)
fmt.Fprint(os.Stderr, usage)
flag.PrintDefaults()
}

Expand Down
20 changes: 20 additions & 0 deletions contracts/ens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Swarm ENS interface

## Usage

Full documentation for the Ethereum Name Service [can be found as EIP 137](https://github.com/ethereum/EIPs/issues/137).
This package offers a simple binding that streamlines the registration of arbitrary UTF8 domain names to swarm content hashes.

## Development

The SOL file in contract subdirectory implements the ENS root registry, a simple
first-in, first-served registrar for the root namespace, and a simple resolver contract;
they're used in tests, and can be used to deploy these contracts for your own purposes.

The solidity source code can be found at [github.com/arachnid/ens/](https://github.com/arachnid/ens/).

The go bindings for ENS contracts are generated using `abigen` via the go generator:

```shell
go generate ./contracts/ens
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 26880b8

Please sign in to comment.