forked from cerc-io/plugeth
Updated tests
This commit is contained in:
parent
5a7eae705b
commit
bb8afba20a
27
block.go
27
block.go
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,21 +44,28 @@ func (block *Block) MarshalRlp() []byte {
|
|||||||
encTx[i] = string(tx.MarshalRlp())
|
encTx[i] = string(tx.MarshalRlp())
|
||||||
}
|
}
|
||||||
|
|
||||||
enc := RlpEncode([]interface{}{
|
header := []interface{}{
|
||||||
block.number,
|
block.number,
|
||||||
block.prevHash,
|
//block.prevHash,
|
||||||
// Sha of uncles
|
// Sha of uncles
|
||||||
block.coinbase,
|
//block.coinbase,
|
||||||
// root state
|
// root state
|
||||||
Sha256Bin([]byte(RlpEncode(encTx))),
|
//Sha256Bin([]byte(RlpEncode(encTx))),
|
||||||
block.difficulty,
|
//block.difficulty,
|
||||||
block.time,
|
//block.time,
|
||||||
block.nonce,
|
//block.nonce,
|
||||||
// extra?
|
// extra?
|
||||||
})
|
}
|
||||||
|
|
||||||
return []byte(enc)
|
return Encode([]interface{}{header, encTx})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (block *Block) UnmarshalRlp(data []byte) {
|
func (block *Block) UnmarshalRlp(data []byte) {
|
||||||
|
fmt.Printf("%q\n", data)
|
||||||
|
t, _ := Decode(data,0)
|
||||||
|
if slice, ok := t.([]interface{}); ok {
|
||||||
|
if txes, ok := slice[1].([]interface{}); ok {
|
||||||
|
fmt.Println(txes[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
15
ethereum.go
15
ethereum.go
@ -9,7 +9,7 @@ func main() {
|
|||||||
|
|
||||||
bm := NewBlockManager()
|
bm := NewBlockManager()
|
||||||
|
|
||||||
tx := NewTransaction(0x0, 20, []string{
|
tx := NewTransaction("\x00", 20, []string{
|
||||||
"SET 10 6",
|
"SET 10 6",
|
||||||
"LD 10 10",
|
"LD 10 10",
|
||||||
"LT 10 1 20",
|
"LT 10 1 20",
|
||||||
@ -23,13 +23,18 @@ func main() {
|
|||||||
"SET 255 15",
|
"SET 255 15",
|
||||||
"JMP 255",
|
"JMP 255",
|
||||||
})
|
})
|
||||||
tx2 := NewTransaction(0x0, 20, []string{"SET 10 6", "LD 10 10"})
|
txData := tx.MarshalRlp()
|
||||||
|
|
||||||
|
copyTx := &Transaction{}
|
||||||
|
copyTx.UnmarshalRlp(txData)
|
||||||
|
|
||||||
|
|
||||||
|
tx2 := NewTransaction("\x00", 20, []string{"SET 10 6", "LD 10 10"})
|
||||||
|
|
||||||
blck := NewBlock([]*Transaction{tx2, tx})
|
blck := NewBlock([]*Transaction{tx2, tx})
|
||||||
|
|
||||||
bm.ProcessBlock( blck )
|
bm.ProcessBlock( blck )
|
||||||
|
|
||||||
//fmt.Printf("rlp encoded Tx %q\n", tx.MarshalRlp())
|
//t := blck.MarshalRlp()
|
||||||
fmt.Printf("block enc %q\n", blck.MarshalRlp())
|
//blck.UnmarshalRlp(t)
|
||||||
fmt.Printf("block hash %q\n", blck.Hash())
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user