@@ -80,91 +80,75 @@ var daoProForkGenesis = `{
8080var daoGenesisHash = common .HexToHash ("5e1fc79cb4ffa4739177b5408045cd5d51c6cf766133f23f7cd72ee1f8d790e0" )
8181var daoGenesisForkBlock = big .NewInt (314 )
8282
83- // Tests that the DAO hard-fork number and the nodes support/opposition is correctly
83+ // TestDAOForkBlockNewChain tests that the DAO hard-fork number and the nodes support/opposition is correctly
8484// set in the database after various initialization procedures and invocations.
85- func TestDAODefaultMainnet (t * testing.T ) {
86- testDAOForkBlockNewChain (t , false , "" , [][2 ]bool {{false , false }}, params .MainNetDAOForkBlock , true )
87- }
88- func TestDAOSupportMainnet (t * testing.T ) {
89- testDAOForkBlockNewChain (t , false , "" , [][2 ]bool {{true , false }}, params .MainNetDAOForkBlock , true )
90- }
91- func TestDAOOpposeMainnet (t * testing.T ) {
92- testDAOForkBlockNewChain (t , false , "" , [][2 ]bool {{false , true }}, params .MainNetDAOForkBlock , false )
93- }
94- func TestDAOSwitchToSupportMainnet (t * testing.T ) {
95- testDAOForkBlockNewChain (t , false , "" , [][2 ]bool {{false , true }, {true , false }}, params .MainNetDAOForkBlock , true )
96- }
97- func TestDAOSwitchToOpposeMainnet (t * testing.T ) {
98- testDAOForkBlockNewChain (t , false , "" , [][2 ]bool {{true , false }, {false , true }}, params .MainNetDAOForkBlock , false )
99- }
100- func TestDAODefaultTestnet (t * testing.T ) {
101- testDAOForkBlockNewChain (t , true , "" , [][2 ]bool {{false , false }}, params .TestNetDAOForkBlock , true )
102- }
103- func TestDAOSupportTestnet (t * testing.T ) {
104- testDAOForkBlockNewChain (t , true , "" , [][2 ]bool {{true , false }}, params .TestNetDAOForkBlock , true )
105- }
106- func TestDAOOpposeTestnet (t * testing.T ) {
107- testDAOForkBlockNewChain (t , true , "" , [][2 ]bool {{false , true }}, params .TestNetDAOForkBlock , false )
108- }
109- func TestDAOSwitchToSupportTestnet (t * testing.T ) {
110- testDAOForkBlockNewChain (t , true , "" , [][2 ]bool {{false , true }, {true , false }}, params .TestNetDAOForkBlock , true )
111- }
112- func TestDAOSwitchToOpposeTestnet (t * testing.T ) {
113- testDAOForkBlockNewChain (t , true , "" , [][2 ]bool {{true , false }, {false , true }}, params .TestNetDAOForkBlock , false )
114- }
115- func TestDAOInitOldPrivnet (t * testing.T ) {
116- testDAOForkBlockNewChain (t , false , daoOldGenesis , [][2 ]bool {}, nil , false )
117- }
118- func TestDAODefaultOldPrivnet (t * testing.T ) {
119- testDAOForkBlockNewChain (t , false , daoOldGenesis , [][2 ]bool {{false , false }}, nil , false )
120- }
121- func TestDAOSupportOldPrivnet (t * testing.T ) {
122- testDAOForkBlockNewChain (t , false , daoOldGenesis , [][2 ]bool {{true , false }}, nil , true )
123- }
124- func TestDAOOpposeOldPrivnet (t * testing.T ) {
125- testDAOForkBlockNewChain (t , false , daoOldGenesis , [][2 ]bool {{false , true }}, nil , false )
126- }
127- func TestDAOSwitchToSupportOldPrivnet (t * testing.T ) {
128- testDAOForkBlockNewChain (t , false , daoOldGenesis , [][2 ]bool {{false , true }, {true , false }}, nil , true )
129- }
130- func TestDAOSwitchToOpposeOldPrivnet (t * testing.T ) {
131- testDAOForkBlockNewChain (t , false , daoOldGenesis , [][2 ]bool {{true , false }, {false , true }}, nil , false )
132- }
133- func TestDAOInitNoForkPrivnet (t * testing.T ) {
134- testDAOForkBlockNewChain (t , false , daoNoForkGenesis , [][2 ]bool {}, daoGenesisForkBlock , false )
135- }
136- func TestDAODefaultNoForkPrivnet (t * testing.T ) {
137- testDAOForkBlockNewChain (t , false , daoNoForkGenesis , [][2 ]bool {{false , false }}, daoGenesisForkBlock , false )
138- }
139- func TestDAOSupportNoForkPrivnet (t * testing.T ) {
140- testDAOForkBlockNewChain (t , false , daoNoForkGenesis , [][2 ]bool {{true , false }}, daoGenesisForkBlock , true )
141- }
142- func TestDAOOpposeNoForkPrivnet (t * testing.T ) {
143- testDAOForkBlockNewChain (t , false , daoNoForkGenesis , [][2 ]bool {{false , true }}, daoGenesisForkBlock , false )
144- }
145- func TestDAOSwitchToSupportNoForkPrivnet (t * testing.T ) {
146- testDAOForkBlockNewChain (t , false , daoNoForkGenesis , [][2 ]bool {{false , true }, {true , false }}, daoGenesisForkBlock , true )
147- }
148- func TestDAOSwitchToOpposeNoForkPrivnet (t * testing.T ) {
149- testDAOForkBlockNewChain (t , false , daoNoForkGenesis , [][2 ]bool {{true , false }, {false , true }}, daoGenesisForkBlock , false )
150- }
151- func TestDAOInitProForkPrivnet (t * testing.T ) {
152- testDAOForkBlockNewChain (t , false , daoProForkGenesis , [][2 ]bool {}, daoGenesisForkBlock , true )
153- }
154- func TestDAODefaultProForkPrivnet (t * testing.T ) {
155- testDAOForkBlockNewChain (t , false , daoProForkGenesis , [][2 ]bool {{false , false }}, daoGenesisForkBlock , true )
156- }
157- func TestDAOSupportProForkPrivnet (t * testing.T ) {
158- testDAOForkBlockNewChain (t , false , daoProForkGenesis , [][2 ]bool {{true , false }}, daoGenesisForkBlock , true )
159- }
160- func TestDAOOpposeProForkPrivnet (t * testing.T ) {
161- testDAOForkBlockNewChain (t , false , daoProForkGenesis , [][2 ]bool {{false , true }}, daoGenesisForkBlock , false )
162- }
163- func TestDAOSwitchToSupportProForkPrivnet (t * testing.T ) {
164- testDAOForkBlockNewChain (t , false , daoProForkGenesis , [][2 ]bool {{false , true }, {true , false }}, daoGenesisForkBlock , true )
165- }
166- func TestDAOSwitchToOpposeProForkPrivnet (t * testing.T ) {
167- testDAOForkBlockNewChain (t , false , daoProForkGenesis , [][2 ]bool {{true , false }, {false , true }}, daoGenesisForkBlock , false )
85+ func TestDAOForkBlockNewChain (t * testing.T ) {
86+ for _ , arg := range []struct {
87+ testnet bool
88+ genesis string
89+ votes [][2 ]bool
90+ expectBlock * big.Int
91+ expectVote bool
92+ }{
93+ // Test DAO Default Mainnet
94+ {false , "" , [][2 ]bool {{false , false }}, params .MainNetDAOForkBlock , true },
95+ // test DAO Support Mainnet
96+ {false , "" , [][2 ]bool {{true , false }}, params .MainNetDAOForkBlock , true },
97+ // test DAO Oppose Mainnet
98+ {false , "" , [][2 ]bool {{false , true }}, params .MainNetDAOForkBlock , false },
99+ // test DAO Switch To Support Mainnet
100+ {false , "" , [][2 ]bool {{false , true }, {true , false }}, params .MainNetDAOForkBlock , true },
101+ // test DAO Switch To Oppose Mainnet
102+ {false , "" , [][2 ]bool {{true , false }, {false , true }}, params .MainNetDAOForkBlock , false },
103+ // test DAO Default Testnet
104+ {true , "" , [][2 ]bool {{false , false }}, params .TestNetDAOForkBlock , true },
105+ // test DAO Support Testnet
106+ {true , "" , [][2 ]bool {{true , false }}, params .TestNetDAOForkBlock , true },
107+ // test DAO Oppose Testnet
108+ {true , "" , [][2 ]bool {{false , true }}, params .TestNetDAOForkBlock , false },
109+ // test DAO Switch To Support Testnet
110+ {true , "" , [][2 ]bool {{false , true }, {true , false }}, params .TestNetDAOForkBlock , true },
111+ // test DAO Switch To Oppose Testnet
112+ {true , "" , [][2 ]bool {{true , false }, {false , true }}, params .TestNetDAOForkBlock , false },
113+ // test DAO Init Old Privnet
114+ {false , daoOldGenesis , [][2 ]bool {}, nil , false },
115+ // test DAO Default Old Privnet
116+ {false , daoOldGenesis , [][2 ]bool {{false , false }}, nil , false },
117+ // test DAO Support Old Privnet
118+ {false , daoOldGenesis , [][2 ]bool {{true , false }}, nil , true },
119+ // test DAO Oppose Old Privnet
120+ {false , daoOldGenesis , [][2 ]bool {{false , true }}, nil , false },
121+ // test DAO Switch To Support Old Privnet
122+ {false , daoOldGenesis , [][2 ]bool {{false , true }, {true , false }}, nil , true },
123+ // test DAO Switch To Oppose Old Privnet
124+ {false , daoOldGenesis , [][2 ]bool {{true , false }, {false , true }}, nil , false },
125+ // test DAO Init No Fork Privnet
126+ {false , daoNoForkGenesis , [][2 ]bool {}, daoGenesisForkBlock , false },
127+ // test DAO Default No Fork Privnet
128+ {false , daoNoForkGenesis , [][2 ]bool {{false , false }}, daoGenesisForkBlock , false },
129+ // test DAO Support No Fork Privnet
130+ {false , daoNoForkGenesis , [][2 ]bool {{true , false }}, daoGenesisForkBlock , true },
131+ // test DAO Oppose No Fork Privnet
132+ {false , daoNoForkGenesis , [][2 ]bool {{false , true }}, daoGenesisForkBlock , false },
133+ // test DAO Switch To Support No Fork Privnet
134+ {false , daoNoForkGenesis , [][2 ]bool {{false , true }, {true , false }}, daoGenesisForkBlock , true },
135+ // test DAO Switch To Oppose No Fork Privnet
136+ {false , daoNoForkGenesis , [][2 ]bool {{true , false }, {false , true }}, daoGenesisForkBlock , false },
137+ // test DAO Init Pro Fork Privnet
138+ {false , daoProForkGenesis , [][2 ]bool {}, daoGenesisForkBlock , true },
139+ // test DAO Default Pro Fork Privnet
140+ {false , daoProForkGenesis , [][2 ]bool {{false , false }}, daoGenesisForkBlock , true },
141+ // test DAO Support Pro Fork Privnet
142+ {false , daoProForkGenesis , [][2 ]bool {{true , false }}, daoGenesisForkBlock , true },
143+ // test DAO Oppose Pro Fork Privnet
144+ {false , daoProForkGenesis , [][2 ]bool {{false , true }}, daoGenesisForkBlock , false },
145+ // test DAO Switch To Support Pro Fork Privnet
146+ {false , daoProForkGenesis , [][2 ]bool {{false , true }, {true , false }}, daoGenesisForkBlock , true },
147+ // test DAO Switch To Oppose Pro Fork Privnet
148+ {false , daoProForkGenesis , [][2 ]bool {{true , false }, {false , true }}, daoGenesisForkBlock , false },
149+ } {
150+ testDAOForkBlockNewChain (t , arg .testnet , arg .genesis , arg .votes , arg .expectBlock , arg .expectVote )
151+ }
168152}
169153
170154func testDAOForkBlockNewChain (t * testing.T , testnet bool , genesis string , votes [][2 ]bool , expectBlock * big.Int , expectVote bool ) {
0 commit comments