2020-11-28 15:08:17 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2021-03-30 09:53:54 +00:00
|
|
|
"context"
|
2020-11-28 15:08:17 +00:00
|
|
|
"testing"
|
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/core"
|
2021-07-28 02:47:38 +00:00
|
|
|
"github.com/ledgerwatch/erigon/ethdb/memdb"
|
2020-11-28 15:08:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetChainConfig(t *testing.T) {
|
2021-07-28 02:47:38 +00:00
|
|
|
db := memdb.NewTestDB(t)
|
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
|
|
|
config, _, err := core.CommitGenesisBlock(db, core.DefaultGenesisBlock())
|
2020-11-28 15:08:17 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("setting up genensis block: %v", err)
|
|
|
|
}
|
2021-01-02 19:28:22 +00:00
|
|
|
|
2021-04-03 06:26:00 +00:00
|
|
|
tx, txErr := db.BeginRo(context.Background())
|
2021-03-30 09:53:54 +00:00
|
|
|
if txErr != nil {
|
|
|
|
t.Fatalf("error starting tx: %v", txErr)
|
|
|
|
}
|
|
|
|
defer tx.Rollback()
|
|
|
|
|
2021-05-01 07:42:23 +00:00
|
|
|
api := &BaseAPI{}
|
2021-03-30 09:53:54 +00:00
|
|
|
config1, err1 := api.chainConfig(tx)
|
2020-11-28 15:08:17 +00:00
|
|
|
if err1 != nil {
|
|
|
|
t.Fatalf("reading chain config: %v", err1)
|
|
|
|
}
|
|
|
|
if config.String() != config1.String() {
|
|
|
|
t.Fatalf("read different config: %s, expected %s", config1.String(), config.String())
|
|
|
|
}
|
2021-03-30 09:53:54 +00:00
|
|
|
config2, err2 := api.chainConfig(tx)
|
2021-01-02 19:28:22 +00:00
|
|
|
if err2 != nil {
|
|
|
|
t.Fatalf("reading chain config: %v", err2)
|
|
|
|
}
|
|
|
|
if config.String() != config2.String() {
|
|
|
|
t.Fatalf("read different config: %s, expected %s", config2.String(), config.String())
|
|
|
|
}
|
2020-11-28 15:08:17 +00:00
|
|
|
}
|