pull/69/head
Minh Doan 6 years ago
parent ef46b60e05
commit bf7b94e832
  1. 10
      blockchain/blockchain.go
  2. 5
      blockchain/transaction.go
  3. 21
      p2p/helper_test.go

@ -205,16 +205,6 @@ func CreateBlockchain(address [20]byte, shardId uint32) *Blockchain {
return &bc
}
// Creat testing genesis block.
func CreateTestingGenesisBlock() *Block {
priIntOne := 111
shardId := uint32(1)
testAddressOne := pki.GetAddressFromInt(priIntOne)
cbtx := NewCoinbaseTX(testAddressOne, genesisCoinbaseData, shardId)
genesis := NewGenesisBlock(cbtx, shardId)
return genesis
}
// Create state block based on the utxos.
func (bc *Blockchain) CreateStateBlock(utxoPool *UTXOPool) *Block {
var numBlocks int32 = 0

@ -7,11 +7,12 @@ import (
"encoding/gob"
"encoding/hex"
"fmt"
"log"
"math"
"github.com/dedis/kyber"
"github.com/dedis/kyber/sign/schnorr"
"github.com/simple-rules/harmony-benchmark/crypto"
"log"
"math"
)
var (

@ -2,13 +2,9 @@ package p2p_test
import (
"bufio"
"bytes"
"encoding/gob"
"net"
"reflect"
"testing"
"github.com/simple-rules/harmony-benchmark/blockchain"
"github.com/simple-rules/harmony-benchmark/p2p"
)
@ -57,20 +53,3 @@ func TestNewNewNode(t *testing.T) {
}
}
}
func TestGobEncode(t *testing.T) {
block := blockchain.CreateTestingGenesisBlock()
var tmp bytes.Buffer
enc := gob.NewEncoder(&tmp)
enc.Encode(*block)
tmp2 := bytes.NewBuffer(tmp.Bytes())
dec := gob.NewDecoder(tmp2)
var block2 blockchain.Block
dec.Decode(&block2)
if !reflect.DeepEqual(*block, block2) {
t.Error("Error in GobEncode")
}
}

Loading…
Cancel
Save