This commit is contained in:
Jae Kwon 2015-07-28 12:13:50 -07:00
parent 3be3647dc8
commit 9f18c80abc
2 changed files with 25 additions and 1 deletions

View File

@ -174,7 +174,7 @@ func toStateAccount(acc *vm.Account) *acm.Account {
if acc.StorageRoot.IsZero() {
storageRoot = nil
} else {
storageRoot = acc.StorageRoot.Bytes()
storageRoot = acc.StorageRoot.Postfix(20)
}
return &acm.Account{
Address: acc.Address.Postfix(20),

24
state/tx_cache_test.go Normal file
View File

@ -0,0 +1,24 @@
package state
import (
"bytes"
"testing"
. "github.com/tendermint/tendermint/common"
"github.com/tendermint/tendermint/wire"
)
func TestStateToFromVMAccount(t *testing.T) {
acmAcc1, _ := RandAccount(true, 456)
acmAcc1.StorageRoot = RandBytes(20)
vmAcc := toVMAccount(acmAcc1)
acmAcc2 := toStateAccount(vmAcc)
acmAcc1Bytes := wire.BinaryBytes(acmAcc1)
acmAcc2Bytes := wire.BinaryBytes(acmAcc2)
if !bytes.Equal(acmAcc1Bytes, acmAcc2Bytes) {
t.Errorf("Unexpected account wire bytes\n%X vs\n%X",
acmAcc1Bytes, acmAcc2Bytes)
}
}