fixes for develop+permissions merge

This commit is contained in:
Jae Kwon
2015-07-07 14:17:20 -07:00
parent 625c72a110
commit 21295f4ae2
6 changed files with 19 additions and 7 deletions

View File

@ -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)

View File

@ -3,6 +3,7 @@ package state
import (
"bytes"
"errors"
"fmt"
"github.com/tendermint/tendermint/account"
. "github.com/tendermint/tendermint/common"

View File

@ -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"`
}

View File

@ -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",

View File

@ -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)

View File

@ -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")
}