From 21295f4ae24686efa2341c35ea985420c2087e83 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 7 Jul 2015 14:17:20 -0700 Subject: [PATCH] fixes for develop+permissions merge --- common/word.go | 11 +++++++++++ state/execution.go | 1 + state/genesis.go | 6 +++--- state/genesis_test.go | 2 +- state/permissions_test.go | 4 ++-- state/state.go | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/common/word.go b/common/word.go index 893b136e6..39e4dbb1c 100644 --- a/common/word.go +++ b/common/word.go @@ -28,6 +28,12 @@ func (w Word256) Compare(other Word256) int { return bytes.Compare(w[:], other[:]) } +func Uint64ToWord256(i uint64) Word256 { + buf := [8]byte{} + PutUint64BE(buf[:], i) + return LeftPadWord256(buf[:]) +} + func Int64ToWord256(i int64) Word256 { buf := [8]byte{} PutInt64BE(buf[:], i) @@ -44,6 +50,11 @@ func LeftPadWord256(bz []byte) (word Word256) { return } +func Uint64FromWord256(word Word256) uint64 { + buf := word.Postfix(8) + return GetUint64BE(buf) +} + func Int64FromWord256(word Word256) int64 { buf := word.Postfix(8) return GetInt64BE(buf) diff --git a/state/execution.go b/state/execution.go index 84e589ebe..20c215179 100644 --- a/state/execution.go +++ b/state/execution.go @@ -3,6 +3,7 @@ package state import ( "bytes" "errors" + "fmt" "github.com/tendermint/tendermint/account" . "github.com/tendermint/tendermint/common" diff --git a/state/genesis.go b/state/genesis.go index fdee9e3fd..34d0432a0 100644 --- a/state/genesis.go +++ b/state/genesis.go @@ -24,19 +24,19 @@ var GenDocKey = []byte("GenDocKey") type BasicAccount struct { Address []byte `json:"address"` - Amount uint64 `json:"amount"` + Amount int64 `json:"amount"` } type GenesisAccount struct { Address []byte `json:"address"` - Amount uint64 `json:"amount"` + Amount int64 `json:"amount"` Name string `json:"name"` Permissions *ptypes.AccountPermissions `json:"permissions"` } type GenesisValidator struct { PubKey account.PubKeyEd25519 `json:"pub_key"` - Amount uint64 `json:"amount"` + Amount int64 `json:"amount"` Name string `json:"name"` UnbondTo []BasicAccount `json:"unbond_to"` } diff --git a/state/genesis_test.go b/state/genesis_test.go index 87716b40d..27b5522a5 100644 --- a/state/genesis_test.go +++ b/state/genesis_test.go @@ -16,7 +16,7 @@ var send1, name1, call1 = 1, 1, 0 var perms, setbit = 66, 70 var accName = "me" var roles1 = []string{"master", "universal-ruler"} -var amt1 uint64 = 1000000 +var amt1 int64 = 1000000 var g1 = fmt.Sprintf(` { "chain_id":"%s", diff --git a/state/permissions_test.go b/state/permissions_test.go index 1ec99c47d..5ffd02441 100644 --- a/state/permissions_test.go +++ b/state/permissions_test.go @@ -478,7 +478,7 @@ func TestCreatePermission(t *testing.T) { t.Fatal("Transaction failed", err) } // ensure the contract is there - contractAddr := NewContractAddress(tx.Input.Address, uint64(tx.Input.Sequence)) + contractAddr := NewContractAddress(tx.Input.Address, tx.Input.Sequence) contractAcc := blockCache.GetAccount(contractAddr) if contractAcc == nil { t.Fatalf("failed to create contract %X", contractAddr) @@ -503,7 +503,7 @@ func TestCreatePermission(t *testing.T) { t.Fatal("Transaction failed", err) } // ensure the contract is there - contractAddr = NewContractAddress(tx.Input.Address, uint64(tx.Input.Sequence)) + contractAddr = NewContractAddress(tx.Input.Address, tx.Input.Sequence) contractAcc = blockCache.GetAccount(contractAddr) if contractAcc == nil { t.Fatalf("failed to create contract %X", contractAddr) diff --git a/state/state.go b/state/state.go index 641036e9f..9db63c7c6 100644 --- a/state/state.go +++ b/state/state.go @@ -254,8 +254,8 @@ func (s *State) releaseValidator(val *Validator) { s.SetValidatorInfo(valInfo) // Send coins back to UnbondTo outputs - // SANITY CHECK accounts, err := getOrMakeOutputs(s, nil, valInfo.UnbondTo) + // SANITY CHECK if err != nil { panic("Couldn't get or make unbondTo accounts") }