Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into chain-id-signer-equal-sigsegv
Browse files Browse the repository at this point in the history
  • Loading branch information
whilei committed May 12, 2017
2 parents 3cd9c82 + ae9a028 commit 50aeb26
Show file tree
Hide file tree
Showing 10 changed files with 485 additions and 146 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ This repository includes several wrappers/executables found in the `cmd` directo

## :green_book: Geth: the basics

### Where does the data live?
By default, geth will store relevant node and blockchain data in a __parent directory__ depending on your OS:
### Data directory
By default, geth will store all node and blockchain data in a __parent directory__ depending on your OS:
- Linux: `$HOME/.ethereum-classic/`
- Mac: `$HOME/Library/EthereumClassic/`
- Windows: `$HOME/AppData/Roaming/EthereumClassic/`

You can specify this directory on the command line using `--data-dir=$HOME/id/rather/put/it/here`.
__You can specify this directory__ with `--data-dir=$HOME/id/rather/put/it/here`.

Within this parent directory, geth will use a __/subdirectory__ to hold data for each network you run. The defaults are:
- `/mainnet` for the Mainnet
- `/morden` for the Morden Testnet (activated with `--testnet`)
- `/morden` for the Morden Testnet

You can specify the subdirectory with the `--chain` flag.
__You can specify this subdirectory__ with `--chain=mycustomnet`.

> __Migrating__: If you have existing data created prior to the [3.4 Release](), geth will attempt to migrate your existing standard ETC data to this structure. To learn more about managing this migration please read our [3.4 release notes on our Releases page](https://github.com/ethereumproject/go-ethereum/wiki/Release-3.4.0-Notes.md).
> __Migrating__: If you have existing data created prior to the [3.4 Release](https://github.com/ethereumproject/go-ethereum/releases), geth will attempt to migrate your existing standard ETC data to this structure. To learn more about managing this migration please read our [3.4 release notes on our Releases page](https://github.com/ethereumproject/go-ethereum/wiki/Release-3.4.0-Notes).
### Full node on the main Ethereum network

Expand Down Expand Up @@ -129,16 +129,18 @@ If you'd like to play around with creating Ethereum contracts, you
almost certainly would like to do that without any real money involved until you get the hang of the entire system. In other words, instead of attaching to the main network, you want to join the **test** network with your node, which is fully equivalent to the main network, but with play-Ether only.

```
$ geth --testnet --fast --cache=512 console
$ geth --chain=morden --fast --cache=512 console
```

The `--fast`, `--cache` flags and `console` subcommand have the exact same meaning as above and they are equally useful on the testnet too. Please see above for their explanations if you've skipped to here.

Specifying the `--testnet` flag will reconfigure your Geth instance a bit:
Specifying the `--chain=morden` flag will reconfigure your Geth instance a bit:

- As mentioned above, Geth will host its testnet data in a `morden` subfolder (`~/.ethereum-classic/morden`).
- Instead of connecting the main Ethereum network, the client will connect to the test network, which uses different P2P bootnodes, different network IDs and genesis states.

You may also optionally use `--testnet` and `--chain=testnet` to enable this configuration. If you'd like to use a custom data subdirectory with a testnet configuration use `--testnet --chain mycustomtestnet`.

> *Note: Although there are some internal protective measures to prevent transactions from crossing over between the main network and test network (different starting nonces), you should make sure to always use separate accounts for play-money and real-money. Unless you manually move accounts, Geth
will by default correctly separate the two networks and will not make any accounts available between them.*

Expand Down
27 changes: 21 additions & 6 deletions cmd/geth/chainconfig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ setup() {
DATA_DIR=`mktemp -d`
default_mainnet_genesis_hash='"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"'
customnet_genesis_hash='"0x76bc07fbdfe084b9aff37425c24453f774d1945b28412a3b4b8c25d8d3c81df2"'
GENESIS_TESTNET=0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303
}

teardown() {
rm -fr $DATA_DIR
unset default_mainnet_genesis_hash
unset customnet_genesis_hash
unset GENESIS_TESTNET
}

## dump-chain-config JSON
Expand Down Expand Up @@ -44,6 +46,19 @@ teardown() {
[[ "$output" == *"\"id\": \"morden\"," ]]
}

@test "--chain morden dump-chain-config | exit 0" {
run $GETH_CMD --datadir $DATA_DIR --chain morden dump-chain-config $DATA_DIR/dump.json
echo "$output"

[ "$status" -eq 0 ]
[[ "$output" == *"Wrote chain config file"* ]]
[ -f $DATA_DIR/dump.json ]
[ -d $DATA_DIR/morden ]

run grep -R "morden" $DATA_DIR/dump.json
[[ "$output" == *"\"id\": \"morden\"," ]]
}

@test "--chain kittyCoin dump-chain-config | exit 0" {
run $GETH_CMD --datadir $DATA_DIR --chain kittyCoin dump-chain-config $DATA_DIR/dump.json
echo "$output"
Expand Down Expand Up @@ -125,10 +140,10 @@ teardown() {
# - external chain config can determine chain configuration
# - use datadir/subdir schema (/morden)
@test "--chain-config config/testnet.json | exit 0" {
run $GETH_CMD --datadir $DATA_DIR --chainconfig $BATS_TEST_DIRNAME/../../cmd/geth/config/testnet.json --maxpeers 0 --nodiscover --nat none --ipcdisable --exec 'eth.getBlock(0).nonce' console
run $GETH_CMD --datadir $DATA_DIR --chainconfig $BATS_TEST_DIRNAME/../../cmd/geth/config/testnet.json --maxpeers 0 --nodiscover --nat none --ipcdisable --exec 'eth.getBlock(0).hash' console
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" == *"0x00006d6f7264656e"* ]]
[[ "$output" == *"0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"* ]]

# Ensure we're using the --chain named subdirectory under main $DATA_DIR.
[ -d $DATA_DIR/morden ]
Expand Down Expand Up @@ -162,28 +177,28 @@ teardown() {
[ -d $DATA_DIR/customnet/keystore ]
}

@test "--chain-config config/testnet.json --testnet | exit >1" {
@test "--chain-config config/testnet.json --testnet | exit >0" {
run $GETH_CMD --data-dir $DATA_DIR --chain-config $BATS_TEST_DIRNAME/../../cmd/geth/config/testnet.json --testnet console
echo "$output"
[ "$status" -gt 0 ]
[[ "$output" == *"invalid flag or context value: invalid chainID: external and flag configurations are conflicting, please use only one"* ]]
}

@test "--chain-config config/mainnet.json --chain mainnet | exit >1" {
@test "--chain-config config/mainnet.json --chain mainnet | exit >0" {
run $GETH_CMD --data-dir $DATA_DIR --chain-config $BATS_TEST_DIRNAME/../../cmd/geth/config/mainnet.json --chain mainnet console
echo "$output"
[ "$status" -gt 0 ]
[[ "$output" == *"invalid flag or context value: invalid chainID: external and flag configurations are conflicting, please use only one"* ]]
}

@test "--chain-config config/mainnet.json --chain kittyCoin | exit >1" {
@test "--chain-config config/mainnet.json --chain kittyCoin | exit >0" {
run $GETH_CMD --data-dir $DATA_DIR --chain-config $BATS_TEST_DIRNAME/../../cmd/geth/config/mainnet.json --chain kittyCoin console
echo "$output"
[ "$status" -gt 0 ]
[[ "$output" == *"invalid flag or context value: invalid chainID: external and flag configurations are conflicting, please use only one"* ]]
}

@test "--chain-config config/mainnet.json --bootnodes=enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303 | exit >1" {
@test "--chain-config config/mainnet.json --bootnodes=enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303 | exit >0" {
run $GETH_CMD --data-dir $DATA_DIR --chain-config $BATS_TEST_DIRNAME/../../cmd/geth/config/mainnet.json --bootnodes=enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303 console
echo "$output"
[ "$status" -gt 0 ]
Expand Down
55 changes: 55 additions & 0 deletions cmd/geth/cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ teardown() {
[[ "$output" == *"USAGE"* ]]
}

@test "exactly overlapping flags allowed: --chain=morden --testnet" {
run $GETH_CMD --data-dir $DATA_DIR --testnet --chain=morden --maxpeers 0 --nodiscover --nat none --ipcdisable --exec 'exit' console
echo "$output"
[ "$status" -eq 0 ]
}

@test "overlapping flags not allowed: --chain=morden --dev" {
run $GETH_CMD --data-dir $DATA_DIR --dev --chain=morden --maxpeers 0 --nodiscover --nat none --ipcdisable --exec 'exit' console
echo "$output"
[ "$status" -gt 0 ]
[[ "$output" == *"invalid flag "* ]]
}

@test "custom testnet subdir --testnet --chain=morden2 | exit 0" {
run $GETH_CMD --data-dir $DATA_DIR --testnet --chain=morden2 --maxpeers 0 --nodiscover --nat none --ipcdisable --exec 'exit' console
echo "$output"
[ "$status" -eq 0 ]

[ -d $DATA_DIR/morden2 ]
}

# TODO
# This doesn't pass, and that's an issue.
# @test "displays help with valid command and invalid subcommand" {
Expand Down Expand Up @@ -144,3 +165,37 @@ teardown() {
[[ "$output" == *"Alloted 17MB cache"* ]]
}

# Ensure --testnet and --chain=morden/testnet set up respective subdirs with default 'morden'
@test "--chain=testnet creates /morden subdir, activating testnet genesis" { # This is kind of weird, but it is expected.
run $GETH_CMD --data-dir $DATA_DIR --chain=testnet --exec 'eth.getBlock(0).hash' console
[ "$status" -eq 0 ]

[[ "$output" == *"0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"* ]]

[ -d $DATA_DIR/morden ]
}

@test "--testnet creates /morden subdir, activating testnet genesis" {
run $GETH_CMD --data-dir $DATA_DIR --testnet --exec 'eth.getBlock(0).hash' console
[ "$status" -eq 0 ]
[[ "$output" == *"0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"* ]]

[ -d $DATA_DIR/morden ]
}

@test "--testnet --chain=faketestnet creates /faketestnet subdir, activating testnet genesis" {
run $GETH_CMD --data-dir $DATA_DIR --testnet --chain=faketestnet --exec 'eth.getBlock(0).hash' console
[ "$status" -eq 0 ]
[[ "$output" == *"0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"* ]]

[ -d $DATA_DIR/faketestnet ]
}

@test "--chain=morden creates /morden subdir, activating testnet genesis" {
run $GETH_CMD --data-dir $DATA_DIR --chain=morden --exec 'eth.getBlock(0).hash' console
[ "$status" -eq 0 ]
[[ "$output" == *"0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"* ]]

[ -d $DATA_DIR/morden ]
}

Loading

0 comments on commit 50aeb26

Please sign in to comment.