updated testing"

This commit is contained in:
obscuren 2014-01-05 20:41:01 +01:00
parent 40dc4d0259
commit 1676930a16
3 changed files with 5 additions and 6 deletions

View File

@ -6,13 +6,13 @@ import (
) )
func TestCompile(t *testing.T) { func TestCompile(t *testing.T) {
instr, err := CompileInstr("SET 10 1") instr, err := CompileInstr("PUSH")
if err != nil { if err != nil {
t.Error("Failed compiling instruction") t.Error("Failed compiling instruction")
} }
calc := (67 + 10 * 256 + 1 * int64(math.Pow(256,2))) calc := (48 + 0 * 256 + 0 * int64(math.Pow(256,2)))
if Big(instr).Int64() != calc { if Big(instr).Int64() != calc {
t.Error("Expected", calc, ", got:", instr) t.Error("Expected", calc, ", got:", instr)
} }

View File

@ -13,8 +13,9 @@ func Testing() {
bm := NewBlockManager() bm := NewBlockManager()
tx := NewTransaction("\x00", 20, []string{"PSH 10"}) tx := NewTransaction("\x00", 20, []string{"PUSH"})
txData := tx.MarshalRlp() txData := tx.MarshalRlp()
fmt.Printf("%q\n", txData)
copyTx := &Transaction{} copyTx := &Transaction{}
copyTx.UnmarshalRlp(txData) copyTx.UnmarshalRlp(txData)

View File

@ -2,7 +2,7 @@ package main
import ( import (
"math/big" "math/big"
"fmt" _"fmt"
"github.com/obscuren/secp256k1-go" "github.com/obscuren/secp256k1-go"
_"encoding/hex" _"encoding/hex"
_"crypto/sha256" _"crypto/sha256"
@ -140,7 +140,6 @@ func (tx *Transaction) MarshalRlp() []byte {
func (tx *Transaction) UnmarshalRlp(data []byte) { func (tx *Transaction) UnmarshalRlp(data []byte) {
t, _ := Decode(data,0) t, _ := Decode(data,0)
if slice, ok := t.([]interface{}); ok { if slice, ok := t.([]interface{}); ok {
fmt.Printf("NONCE %T\n", slice[3])
if nonce, ok := slice[0].(uint8); ok { if nonce, ok := slice[0].(uint8); ok {
tx.nonce = string(nonce) tx.nonce = string(nonce)
} }
@ -186,7 +185,6 @@ func (tx *Transaction) UnmarshalRlp(data []byte) {
} }
// vrs // vrs
fmt.Printf("v %T\n", slice[5])
if v, ok := slice[5].(uint8); ok { if v, ok := slice[5].(uint8); ok {
tx.v = uint32(v) tx.v = uint32(v)
} }