github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/store/mainchain/extstorages/league_account_test.go (about) 1 package extstorages 2 3 import ( 4 "testing" 5 6 "os" 7 8 "fmt" 9 10 "math/big" 11 12 "github.com/sixexorg/magnetic-ring/common" 13 "github.com/sixexorg/magnetic-ring/mock" 14 "github.com/sixexorg/magnetic-ring/store/mainchain/extstates" 15 ) 16 17 func TestGetAccountByHeight(t *testing.T) { 18 account, err := accountStore.GetAccountByHeight(mock.Address_1, mock.LeagueAddress1, 1) 19 if err != nil { 20 t.Error(err) 21 t.Fail() 22 return 23 } 24 t.Log(account) 25 } 26 27 func TestGetPrev(t *testing.T) { 28 dbDir := "./testAccount" 29 os.RemoveAll(dbDir) 30 leagueId := common.Address{1, 2, 3} 31 account := common.Address{3, 4, 5} 32 store, _ := NewExternalLeague(dbDir, false) 33 34 las := &extstates.LeagueAccountState{ 35 Address: account, 36 LeagueId: leagueId, 37 Height: 30, 38 Data: &extstates.Account{ 39 Nonce: 2, 40 Balance: big.NewInt(20000), 41 EnergyBalance: big.NewInt(23333), 42 BonusHeight: 0, 43 }, 44 } 45 err := store.Save(las) 46 if err != nil { 47 t.Error(err) 48 return 49 } 50 ass, err := store.GetPrev(50, account, leagueId) 51 fmt.Println(ass, err) 52 }