This commit is contained in:
xiekeyang 2016-10-29 10:09:27 +00:00 committed by GitHub
commit d39e749e8b

View file

@ -82,89 +82,74 @@ var daoGenesisForkBlock = big.NewInt(314)
// Tests that the DAO hard-fork number and the nodes support/opposition is correctly // Tests that the DAO hard-fork number and the nodes support/opposition is correctly
// set in the database after various initialization procedures and invocations. // 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 TestDAOForkBlockNewChain(t *testing.T) {
} for _, arg := range []struct {
func TestDAOSupportMainnet(t *testing.T) { testnet bool
testDAOForkBlockNewChain(t, false, "", [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true) genesis string
} votes [][2]bool
func TestDAOOpposeMainnet(t *testing.T) { expectBlock *big.Int
testDAOForkBlockNewChain(t, false, "", [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false) expectVote bool
} }{
func TestDAOSwitchToSupportMainnet(t *testing.T) { // test DAO default main net
testDAOForkBlockNewChain(t, false, "", [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true) {false, "", [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true},
} // test DAO support main net
func TestDAOSwitchToOpposeMainnet(t *testing.T) { {false, "", [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true},
testDAOForkBlockNewChain(t, false, "", [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false) // test DAO oppose main net
} {false, "", [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false},
func TestDAODefaultTestnet(t *testing.T) { // test DAO switch to support main net
testDAOForkBlockNewChain(t, true, "", [][2]bool{{false, false}}, params.TestNetDAOForkBlock, true) {false, "", [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true},
} // test DAO oppose main net
func TestDAOSupportTestnet(t *testing.T) { {false, "", [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false},
testDAOForkBlockNewChain(t, true, "", [][2]bool{{true, false}}, params.TestNetDAOForkBlock, true) // test DAO default test net
} {true, "", [][2]bool{{false, false}}, params.TestNetDAOForkBlock, true},
func TestDAOOpposeTestnet(t *testing.T) { // test DAO support test net
testDAOForkBlockNewChain(t, true, "", [][2]bool{{false, true}}, params.TestNetDAOForkBlock, false) {true, "", [][2]bool{{true, false}}, params.TestNetDAOForkBlock, true},
} // test DAO oppose test net
func TestDAOSwitchToSupportTestnet(t *testing.T) { {true, "", [][2]bool{{false, true}}, params.TestNetDAOForkBlock, false},
testDAOForkBlockNewChain(t, true, "", [][2]bool{{false, true}, {true, false}}, params.TestNetDAOForkBlock, true) // test DAO switch to support test net
} {true, "", [][2]bool{{false, true}, {true, false}}, params.TestNetDAOForkBlock, true},
func TestDAOSwitchToOpposeTestnet(t *testing.T) { // test DAO switch to oppose test net
testDAOForkBlockNewChain(t, true, "", [][2]bool{{true, false}, {false, true}}, params.TestNetDAOForkBlock, false) {true, "", [][2]bool{{true, false}, {false, true}}, params.TestNetDAOForkBlock, false},
} // test DAO init old private net
func TestDAOInitOldPrivnet(t *testing.T) { {false, daoOldGenesis, [][2]bool{}, nil, false},
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{}, nil, false) // test DAO default old private net
} {false, daoOldGenesis, [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true},
func TestDAODefaultOldPrivnet(t *testing.T) { // test DAO support old private net
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true) {false, daoOldGenesis, [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true},
} // test DAO oppose old private net
func TestDAOSupportOldPrivnet(t *testing.T) { {false, daoOldGenesis, [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false},
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true) // test DAO switch to support old private net
} {false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true},
func TestDAOOpposeOldPrivnet(t *testing.T) { // test DAO switch to oppose old private net
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false) {false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false},
} // test DAO init no fork private net
func TestDAOSwitchToSupportOldPrivnet(t *testing.T) { {false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false},
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true) // test DAO default no fork private net
} {false, daoNoForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, false},
func TestDAOSwitchToOpposeOldPrivnet(t *testing.T) { // test DAO support no fork private net
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false) {false, daoNoForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true},
} // test DAO oppose no fork private net
func TestDAOInitNoForkPrivnet(t *testing.T) { {false, daoNoForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false},
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false) // test DAO switch to support no fork private net
} {false, daoNoForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true},
func TestDAODefaultNoForkPrivnet(t *testing.T) { // test DAO switch to oppose no fork private net
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, false) {false, daoNoForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false},
} // test DAO init pro fork private net
func TestDAOSupportNoForkPrivnet(t *testing.T) { {false, daoProForkGenesis, [][2]bool{}, daoGenesisForkBlock, true},
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true) // test DAO default pro fork private net
} {false, daoProForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, true},
func TestDAOOpposeNoForkPrivnet(t *testing.T) { // test DAO support pro fork private net
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false) {false, daoProForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true},
} // test DAO oppose pro fork private net
func TestDAOSwitchToSupportNoForkPrivnet(t *testing.T) { {false, daoProForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false},
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true) // test DAO switch to support pro fork private net
} {false, daoProForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true},
func TestDAOSwitchToOpposeNoForkPrivnet(t *testing.T) { // test DAO switch to oppose pro fork private net
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false) {false, daoProForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false},
} } {
func TestDAOInitProForkPrivnet(t *testing.T) { testDAOForkBlockNewChain(t, arg.testnet, arg.genesis, arg.votes, arg.expectBlock, arg.expectVote)
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, testnet bool, genesis string, votes [][2]bool, expectBlock *big.Int, expectVote bool) { func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes [][2]bool, expectBlock *big.Int, expectVote bool) {