Browse Source

fixes for develop+permissions merge

pull/102/head
Jae Kwon 9 years ago
parent
commit
21295f4ae2
6 changed files with 19 additions and 7 deletions
  1. +11
    -0
      common/word.go
  2. +1
    -0
      state/execution.go
  3. +3
    -3
      state/genesis.go
  4. +1
    -1
      state/genesis_test.go
  5. +2
    -2
      state/permissions_test.go
  6. +1
    -1
      state/state.go

+ 11
- 0
common/word.go View File

@ -28,6 +28,12 @@ func (w Word256) Compare(other Word256) int {
return bytes.Compare(w[:], other[:]) return bytes.Compare(w[:], other[:])
} }
func Uint64ToWord256(i uint64) Word256 {
buf := [8]byte{}
PutUint64BE(buf[:], i)
return LeftPadWord256(buf[:])
}
func Int64ToWord256(i int64) Word256 { func Int64ToWord256(i int64) Word256 {
buf := [8]byte{} buf := [8]byte{}
PutInt64BE(buf[:], i) PutInt64BE(buf[:], i)
@ -44,6 +50,11 @@ func LeftPadWord256(bz []byte) (word Word256) {
return return
} }
func Uint64FromWord256(word Word256) uint64 {
buf := word.Postfix(8)
return GetUint64BE(buf)
}
func Int64FromWord256(word Word256) int64 { func Int64FromWord256(word Word256) int64 {
buf := word.Postfix(8) buf := word.Postfix(8)
return GetInt64BE(buf) return GetInt64BE(buf)


+ 1
- 0
state/execution.go View File

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


+ 3
- 3
state/genesis.go View File

@ -24,19 +24,19 @@ var GenDocKey = []byte("GenDocKey")
type BasicAccount struct { type BasicAccount struct {
Address []byte `json:"address"` Address []byte `json:"address"`
Amount uint64 `json:"amount"`
Amount int64 `json:"amount"`
} }
type GenesisAccount struct { type GenesisAccount struct {
Address []byte `json:"address"` Address []byte `json:"address"`
Amount uint64 `json:"amount"`
Amount int64 `json:"amount"`
Name string `json:"name"` Name string `json:"name"`
Permissions *ptypes.AccountPermissions `json:"permissions"` Permissions *ptypes.AccountPermissions `json:"permissions"`
} }
type GenesisValidator struct { type GenesisValidator struct {
PubKey account.PubKeyEd25519 `json:"pub_key"` PubKey account.PubKeyEd25519 `json:"pub_key"`
Amount uint64 `json:"amount"`
Amount int64 `json:"amount"`
Name string `json:"name"` Name string `json:"name"`
UnbondTo []BasicAccount `json:"unbond_to"` UnbondTo []BasicAccount `json:"unbond_to"`
} }


+ 1
- 1
state/genesis_test.go View File

@ -16,7 +16,7 @@ var send1, name1, call1 = 1, 1, 0
var perms, setbit = 66, 70 var perms, setbit = 66, 70
var accName = "me" var accName = "me"
var roles1 = []string{"master", "universal-ruler"} var roles1 = []string{"master", "universal-ruler"}
var amt1 uint64 = 1000000
var amt1 int64 = 1000000
var g1 = fmt.Sprintf(` var g1 = fmt.Sprintf(`
{ {
"chain_id":"%s", "chain_id":"%s",


+ 2
- 2
state/permissions_test.go View File

@ -478,7 +478,7 @@ func TestCreatePermission(t *testing.T) {
t.Fatal("Transaction failed", err) t.Fatal("Transaction failed", err)
} }
// ensure the contract is there // 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) contractAcc := blockCache.GetAccount(contractAddr)
if contractAcc == nil { if contractAcc == nil {
t.Fatalf("failed to create contract %X", contractAddr) t.Fatalf("failed to create contract %X", contractAddr)
@ -503,7 +503,7 @@ func TestCreatePermission(t *testing.T) {
t.Fatal("Transaction failed", err) t.Fatal("Transaction failed", err)
} }
// ensure the contract is there // 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) contractAcc = blockCache.GetAccount(contractAddr)
if contractAcc == nil { if contractAcc == nil {
t.Fatalf("failed to create contract %X", contractAddr) t.Fatalf("failed to create contract %X", contractAddr)


+ 1
- 1
state/state.go View File

@ -254,8 +254,8 @@ func (s *State) releaseValidator(val *Validator) {
s.SetValidatorInfo(valInfo) s.SetValidatorInfo(valInfo)
// Send coins back to UnbondTo outputs // Send coins back to UnbondTo outputs
// SANITY CHECK
accounts, err := getOrMakeOutputs(s, nil, valInfo.UnbondTo) accounts, err := getOrMakeOutputs(s, nil, valInfo.UnbondTo)
// SANITY CHECK
if err != nil { if err != nil {
panic("Couldn't get or make unbondTo accounts") panic("Couldn't get or make unbondTo accounts")
} }


Loading…
Cancel
Save