aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorxiekeyang <xiekeyang@users.noreply.github.com>2016-11-09 10:15:48 +0800
committerFelix Lange <fjl@twurst.com>2016-11-09 10:15:48 +0800
commit5b31794dfe154d8efa04fbe1606be0b582ee140c (patch)
tree46829a95405a3412d8912bb4c6eea363c9d4aebe /cmd/geth
parent355f4b0c15fadec683877b5de1361bd678fee28e (diff)
downloadgo-tangerine-5b31794dfe154d8efa04fbe1606be0b582ee140c.tar
go-tangerine-5b31794dfe154d8efa04fbe1606be0b582ee140c.tar.gz
go-tangerine-5b31794dfe154d8efa04fbe1606be0b582ee140c.tar.bz2
go-tangerine-5b31794dfe154d8efa04fbe1606be0b582ee140c.tar.lz
go-tangerine-5b31794dfe154d8efa04fbe1606be0b582ee140c.tar.xz
go-tangerine-5b31794dfe154d8efa04fbe1606be0b582ee140c.tar.zst
go-tangerine-5b31794dfe154d8efa04fbe1606be0b582ee140c.zip
cmd/geth: use a loop in TestDAOForkBlockNewChain (#3222)
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/dao_test.go152
1 files changed, 68 insertions, 84 deletions
diff --git a/cmd/geth/dao_test.go b/cmd/geth/dao_test.go
index 56e77ba0b..f90bb182d 100644
--- a/cmd/geth/dao_test.go
+++ b/cmd/geth/dao_test.go
@@ -80,91 +80,75 @@ var daoProForkGenesis = `{
var daoGenesisHash = common.HexToHash("5e1fc79cb4ffa4739177b5408045cd5d51c6cf766133f23f7cd72ee1f8d790e0")
var daoGenesisForkBlock = big.NewInt(314)
-// Tests that the DAO hard-fork number and the nodes support/opposition is correctly
+// TestDAOForkBlockNewChain tests that the DAO hard-fork number and the nodes support/opposition is correctly
// set in the database after various initialization procedures and invocations.
-func TestDAODefaultMainnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, "", [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true)
-}
-func TestDAOSupportMainnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, "", [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true)
-}
-func TestDAOOpposeMainnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, "", [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false)
-}
-func TestDAOSwitchToSupportMainnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, "", [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true)
-}
-func TestDAOSwitchToOpposeMainnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, "", [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false)
-}
-func TestDAODefaultTestnet(t *testing.T) {
- testDAOForkBlockNewChain(t, true, "", [][2]bool{{false, false}}, params.TestNetDAOForkBlock, true)
-}
-func TestDAOSupportTestnet(t *testing.T) {
- testDAOForkBlockNewChain(t, true, "", [][2]bool{{true, false}}, params.TestNetDAOForkBlock, true)
-}
-func TestDAOOpposeTestnet(t *testing.T) {
- testDAOForkBlockNewChain(t, true, "", [][2]bool{{false, true}}, params.TestNetDAOForkBlock, false)
-}
-func TestDAOSwitchToSupportTestnet(t *testing.T) {
- testDAOForkBlockNewChain(t, true, "", [][2]bool{{false, true}, {true, false}}, params.TestNetDAOForkBlock, true)
-}
-func TestDAOSwitchToOpposeTestnet(t *testing.T) {
- testDAOForkBlockNewChain(t, true, "", [][2]bool{{true, false}, {false, true}}, params.TestNetDAOForkBlock, false)
-}
-func TestDAOInitOldPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{}, nil, false)
-}
-func TestDAODefaultOldPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, false}}, nil, false)
-}
-func TestDAOSupportOldPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}}, nil, true)
-}
-func TestDAOOpposeOldPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}}, nil, false)
-}
-func TestDAOSwitchToSupportOldPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, nil, true)
-}
-func TestDAOSwitchToOpposeOldPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, nil, false)
-}
-func TestDAOInitNoForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false)
-}
-func TestDAODefaultNoForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, false)
-}
-func TestDAOSupportNoForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true)
-}
-func TestDAOOpposeNoForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false)
-}
-func TestDAOSwitchToSupportNoForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true)
-}
-func TestDAOSwitchToOpposeNoForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false)
-}
-func TestDAOInitProForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoProForkGenesis, [][2]bool{}, daoGenesisForkBlock, true)
-}
-func TestDAODefaultProForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoProForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, true)
-}
-func TestDAOSupportProForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoProForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true)
-}
-func TestDAOOpposeProForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoProForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false)
-}
-func TestDAOSwitchToSupportProForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoProForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true)
-}
-func TestDAOSwitchToOpposeProForkPrivnet(t *testing.T) {
- testDAOForkBlockNewChain(t, false, daoProForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false)
+func TestDAOForkBlockNewChain(t *testing.T) {
+ for _, arg := range []struct {
+ testnet bool
+ genesis string
+ votes [][2]bool
+ expectBlock *big.Int
+ expectVote bool
+ }{
+ // Test DAO Default Mainnet
+ {false, "", [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true},
+ // test DAO Support Mainnet
+ {false, "", [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true},
+ // test DAO Oppose Mainnet
+ {false, "", [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false},
+ // test DAO Switch To Support Mainnet
+ {false, "", [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true},
+ // test DAO Switch To Oppose Mainnet
+ {false, "", [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false},
+ // test DAO Default Testnet
+ {true, "", [][2]bool{{false, false}}, params.TestNetDAOForkBlock, true},
+ // test DAO Support Testnet
+ {true, "", [][2]bool{{true, false}}, params.TestNetDAOForkBlock, true},
+ // test DAO Oppose Testnet
+ {true, "", [][2]bool{{false, true}}, params.TestNetDAOForkBlock, false},
+ // test DAO Switch To Support Testnet
+ {true, "", [][2]bool{{false, true}, {true, false}}, params.TestNetDAOForkBlock, true},
+ // test DAO Switch To Oppose Testnet
+ {true, "", [][2]bool{{true, false}, {false, true}}, params.TestNetDAOForkBlock, false},
+ // test DAO Init Old Privnet
+ {false, daoOldGenesis, [][2]bool{}, nil, false},
+ // test DAO Default Old Privnet
+ {false, daoOldGenesis, [][2]bool{{false, false}}, nil, false},
+ // test DAO Support Old Privnet
+ {false, daoOldGenesis, [][2]bool{{true, false}}, nil, true},
+ // test DAO Oppose Old Privnet
+ {false, daoOldGenesis, [][2]bool{{false, true}}, nil, false},
+ // test DAO Switch To Support Old Privnet
+ {false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, nil, true},
+ // test DAO Switch To Oppose Old Privnet
+ {false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, nil, false},
+ // test DAO Init No Fork Privnet
+ {false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false},
+ // test DAO Default No Fork Privnet
+ {false, daoNoForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, false},
+ // test DAO Support No Fork Privnet
+ {false, daoNoForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true},
+ // test DAO Oppose No Fork Privnet
+ {false, daoNoForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false},
+ // test DAO Switch To Support No Fork Privnet
+ {false, daoNoForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true},
+ // test DAO Switch To Oppose No Fork Privnet
+ {false, daoNoForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false},
+ // test DAO Init Pro Fork Privnet
+ {false, daoProForkGenesis, [][2]bool{}, daoGenesisForkBlock, true},
+ // test DAO Default Pro Fork Privnet
+ {false, daoProForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, true},
+ // test DAO Support Pro Fork Privnet
+ {false, daoProForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true},
+ // test DAO Oppose Pro Fork Privnet
+ {false, daoProForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false},
+ // test DAO Switch To Support Pro Fork Privnet
+ {false, daoProForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true},
+ // test DAO Switch To Oppose Pro Fork Privnet
+ {false, daoProForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false},
+ } {
+ testDAOForkBlockNewChain(t, arg.testnet, arg.genesis, arg.votes, arg.expectBlock, arg.expectVote)
+ }
}
func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes [][2]bool, expectBlock *big.Int, expectVote bool) {