github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/store/mainchain/genesis/gensis_test.go (about)

     1  package genesis
     2  
     3  import (
     4  	"testing"
     5  
     6  	"os"
     7  
     8  	"fmt"
     9  
    10  	"github.com/sixexorg/magnetic-ring/common"
    11  	"github.com/sixexorg/magnetic-ring/config"
    12  	_ "github.com/sixexorg/magnetic-ring/mock"
    13  	"github.com/sixexorg/magnetic-ring/store/mainchain/storages"
    14  )
    15  
    16  func TestGenesis(t *testing.T) {
    17  	dbDir := "test"
    18  	defer os.RemoveAll(dbDir)
    19  	ledger, _ := storages.NewLedgerStore("dbDir")
    20  	genconf := &Genesis{
    21  		Config: &config.GenesisConfig{
    22  			ChainId:   "1",
    23  			crystal:       10000000,
    24  			Energy:      20000000,
    25  			Timestamp: 12345678,
    26  			Official:  "04dc2c38fd4985a30f31fe9ab0e1d6ffa85d33d5c8f0a5ff38c45534e8f4ffe751055e6f1bbec984839dd772a68794722683ed12994feb84a13b8086162591418e",
    27  			Stars: []*config.StarNode{
    28  				{
    29  					Account: common.Address{1, 2, 3}.ToString(),
    30  					crystal:     20000,
    31  					Nodekey: "04dc2c38fd4985a30f31fe9ab0e1d6ffa85d33d5c8f0a5ff38c45534e8f4ffe751055e6f1bbec984839dd772a68794722683ed12994feb84a13b8086162591418f",
    32  				},
    33  			},
    34  		},
    35  	}
    36  	genconf.GenesisBlock(ledger)
    37  
    38  	ass, _ := genconf.genFirst()
    39  	ast, err := ledger.GetAccountByHeight(2, ass[0].Address)
    40  	if err != nil {
    41  		t.Error(err)
    42  		t.Fail()
    43  		return
    44  	}
    45  	t.Log(ast.Data.Balance)
    46  	block, err := ledger.GetBlockByHeight(1)
    47  	if err != nil {
    48  		t.Error(err)
    49  		t.Fail()
    50  		return
    51  	}
    52  	fmt.Println(block)
    53  }