@@ -134,15 +134,16 @@ func TestCreateBlockchain(t *testing.T) {
134
134
assert := assert .New (t )
135
135
ctx := context .Background ()
136
136
137
- config , err := config .LoadConfigWithPathWithoutValidation (testingConfigPath )
137
+ config .Path = testingConfigPath
138
+ cfg , err := config .New ()
138
139
assert .Nil (err )
139
140
// disable account-based testing
140
- config .Chain .TrieDBPath = ""
141
+ cfg .Chain .TrieDBPath = ""
141
142
// Disable block reward to make bookkeeping easier
142
143
Gen .BlockReward = uint64 (0 )
143
144
144
145
// create chain
145
- bc := NewBlockchain (config , InMemDaoOption ())
146
+ bc := NewBlockchain (cfg , InMemDaoOption ())
146
147
assert .NotNil (bc )
147
148
height , err := bc .TipHeight ()
148
149
assert .Nil (err )
@@ -187,7 +188,8 @@ func TestCreateBlockchain(t *testing.T) {
187
188
func TestLoadBlockchainfromDB (t * testing.T ) {
188
189
require := require .New (t )
189
190
190
- config , err := config .LoadConfigWithPathWithoutValidation (testingConfigPath )
191
+ config .Path = testingConfigPath
192
+ cfg , err := config .New ()
191
193
require .Nil (err )
192
194
util .CleanupPath (t , testTriePath )
193
195
defer util .CleanupPath (t , testTriePath )
@@ -197,15 +199,15 @@ func TestLoadBlockchainfromDB(t *testing.T) {
197
199
// Disable block reward to make bookkeeping easier
198
200
Gen .BlockReward = uint64 (0 )
199
201
200
- config .Chain .TrieDBPath = testTriePath
201
- config .Chain .ChainDBPath = testDBPath
202
+ cfg .Chain .TrieDBPath = testTriePath
203
+ cfg .Chain .ChainDBPath = testDBPath
202
204
203
- sf , err := state .NewFactory (config , state .DefaultTrieOption ())
205
+ sf , err := state .NewFactory (cfg , state .DefaultTrieOption ())
204
206
require .Nil (err )
205
207
sf .CreateState (ta .Addrinfo ["miner" ].RawAddress , Gen .TotalSupply )
206
208
207
209
// Create a blockchain from scratch
208
- bc := NewBlockchain (config , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
210
+ bc := NewBlockchain (cfg , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
209
211
require .NotNil (bc )
210
212
height , err := bc .TipHeight ()
211
213
require .Nil (err )
@@ -215,7 +217,7 @@ func TestLoadBlockchainfromDB(t *testing.T) {
215
217
bc .Stop (ctx )
216
218
217
219
// Load a blockchain from DB
218
- bc = NewBlockchain (config , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
220
+ bc = NewBlockchain (cfg , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
219
221
defer bc .Stop (ctx )
220
222
require .NotNil (bc )
221
223
@@ -377,13 +379,14 @@ func TestLoadBlockchainfromDB(t *testing.T) {
377
379
}
378
380
379
381
func TestBlockchain_Validator (t * testing.T ) {
380
- config , err := config .LoadConfigWithPathWithoutValidation (testingConfigPath )
382
+ config .Path = testingConfigPath
383
+ cfg , err := config .New ()
381
384
assert .Nil (t , err )
382
385
// disable account-based testing
383
- config .Chain .TrieDBPath = ""
386
+ cfg .Chain .TrieDBPath = ""
384
387
385
388
ctx := context .Background ()
386
- bc := NewBlockchain (config , InMemDaoOption (), InMemStateFactoryOption ())
389
+ bc := NewBlockchain (cfg , InMemDaoOption (), InMemStateFactoryOption ())
387
390
defer bc .Stop (ctx )
388
391
assert .NotNil (t , bc )
389
392
@@ -394,13 +397,14 @@ func TestBlockchain_Validator(t *testing.T) {
394
397
}
395
398
396
399
func TestBlockchain_MintNewDummyBlock (t * testing.T ) {
397
- config , err := config .LoadConfigWithPathWithoutValidation (testingConfigPath )
400
+ config .Path = testingConfigPath
401
+ cfg , err := config .New ()
398
402
assert .Nil (t , err )
399
403
// disable account-based testing
400
- config .Chain .TrieDBPath = ""
404
+ cfg .Chain .TrieDBPath = ""
401
405
402
406
ctx := context .Background ()
403
- bc := NewBlockchain (config , InMemDaoOption (), InMemStateFactoryOption ())
407
+ bc := NewBlockchain (cfg , InMemDaoOption (), InMemStateFactoryOption ())
404
408
defer bc .Stop (ctx )
405
409
assert .NotNil (t , bc )
406
410
@@ -412,25 +416,26 @@ func TestBlockchain_MintNewDummyBlock(t *testing.T) {
412
416
func TestBlockchainInitialCandidate (t * testing.T ) {
413
417
require := require .New (t )
414
418
415
- config , err := config .LoadConfigWithPathWithoutValidation (testingConfigPath )
419
+ config .Path = testingConfigPath
420
+ cfg , err := config .New ()
416
421
require .Nil (err )
417
422
util .CleanupPath (t , testTriePath )
418
423
defer util .CleanupPath (t , testTriePath )
419
424
util .CleanupPath (t , testDBPath )
420
425
defer util .CleanupPath (t , testDBPath )
421
426
422
- config .Chain .TrieDBPath = testTriePath
423
- config .Chain .ChainDBPath = testDBPath
427
+ cfg .Chain .TrieDBPath = testTriePath
428
+ cfg .Chain .ChainDBPath = testDBPath
424
429
// Disable block reward to make bookkeeping easier
425
430
Gen .BlockReward = uint64 (0 )
426
431
427
- sf , err := state .NewFactory (config , state .DefaultTrieOption ())
432
+ sf , err := state .NewFactory (cfg , state .DefaultTrieOption ())
428
433
require .Nil (err )
429
434
430
435
height , candidate := sf .Candidates ()
431
436
require .True (height == 0 )
432
437
require .True (len (candidate ) == 0 )
433
- bc := NewBlockchain (config , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
438
+ bc := NewBlockchain (cfg , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
434
439
require .NotNil (t , bc )
435
440
// TODO: change the value when Candidates size is changed
436
441
height , candidate = sf .Candidates ()
@@ -440,23 +445,24 @@ func TestBlockchainInitialCandidate(t *testing.T) {
440
445
441
446
func TestCoinbaseTransfer (t * testing.T ) {
442
447
require := require .New (t )
443
- config , err := config .LoadConfigWithPathWithoutValidation (testingConfigPath )
448
+ config .Path = testingConfigPath
449
+ cfg , err := config .New ()
444
450
require .Nil (err )
445
451
util .CleanupPath (t , testTriePath )
446
452
defer util .CleanupPath (t , testTriePath )
447
453
util .CleanupPath (t , testDBPath )
448
454
defer util .CleanupPath (t , testDBPath )
449
455
450
- config .Chain .TrieDBPath = testTriePath
451
- config .Chain .ChainDBPath = testDBPath
456
+ cfg .Chain .TrieDBPath = testTriePath
457
+ cfg .Chain .ChainDBPath = testDBPath
452
458
453
- sf , err := state .NewFactory (config , state .DefaultTrieOption ())
459
+ sf , err := state .NewFactory (cfg , state .DefaultTrieOption ())
454
460
require .Nil (err )
455
461
sf .CreateState (ta .Addrinfo ["miner" ].RawAddress , Gen .TotalSupply )
456
462
457
463
Gen .BlockReward = uint64 (10 )
458
464
459
- bc := NewBlockchain (config , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
465
+ bc := NewBlockchain (cfg , PrecreatedStateFactoryOption (sf ), BoltDBDaoOption ())
460
466
require .NotNil (bc )
461
467
height , err := bc .TipHeight ()
462
468
require .Nil (err )
@@ -484,11 +490,12 @@ func TestCoinbaseTransfer(t *testing.T) {
484
490
func TestBlockchain_StateByAddr (t * testing.T ) {
485
491
require := require .New (t )
486
492
487
- config , err := config .LoadConfigWithPathWithoutValidation (testingConfigPath )
493
+ config .Path = testingConfigPath
494
+ cfg , err := config .New ()
488
495
require .Nil (err )
489
496
// disable account-based testing
490
497
// create chain
491
- bc := NewBlockchain (config , InMemDaoOption (), InMemStateFactoryOption ())
498
+ bc := NewBlockchain (cfg , InMemDaoOption (), InMemStateFactoryOption ())
492
499
require .NotNil (bc )
493
500
494
501
s , _ := bc .StateByAddr (Gen .CreatorAddr )
0 commit comments