Fixes #121
This commit is contained in:
parent
3be3647dc8
commit
9f18c80abc
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue