2014-10-10 20:44:20 +00:00
|
|
|
package ar
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math/big"
|
|
|
|
"testing"
|
|
|
|
|
2014-10-23 13:01:27 +00:00
|
|
|
"github.com/ethereum/go-ethereum/ethdb"
|
2014-10-31 17:40:32 +00:00
|
|
|
"github.com/ethereum/go-ethereum/trie"
|
2014-10-10 20:44:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type TestBlock struct {
|
2014-10-31 17:40:32 +00:00
|
|
|
trie *trie.Trie
|
2014-10-10 20:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewTestBlock() *TestBlock {
|
|
|
|
db, _ := ethdb.NewMemDatabase()
|
|
|
|
return &TestBlock{
|
2014-10-31 17:40:32 +00:00
|
|
|
trie: trie.New(db, ""),
|
2014-10-10 20:44:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *TestBlock) Diff() *big.Int {
|
|
|
|
return b(10)
|
|
|
|
}
|
|
|
|
|
2014-10-31 17:40:32 +00:00
|
|
|
func (self *TestBlock) Trie() *trie.Trie {
|
2014-10-10 20:44:20 +00:00
|
|
|
return self.trie
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *TestBlock) Hash() []byte {
|
|
|
|
a := make([]byte, 32)
|
|
|
|
a[0] = 10
|
|
|
|
a[1] = 2
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPow(t *testing.T) {
|
|
|
|
entry := make([]byte, 32)
|
|
|
|
entry[0] = 255
|
|
|
|
|
|
|
|
block := NewTestBlock()
|
|
|
|
|
|
|
|
pow := NewTape(block)
|
|
|
|
nonce := pow.Run(block.Hash())
|
|
|
|
fmt.Println("Found nonce", nonce)
|
|
|
|
}
|