mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 01:41:31 +00:00
.
This commit is contained in:
@ -28,6 +28,13 @@ func (self *Block) Validate() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Block) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
n, err = WriteOnto(&self.Header, w, n, err)
|
||||||
|
n, err = WriteOnto(&self.Validation, w, n, err)
|
||||||
|
n, err = WriteOnto(&self.Data, w, n, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Block > Header */
|
/* Block > Header */
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package blocks
|
|||||||
import (
|
import (
|
||||||
. "github.com/tendermint/tendermint/binary"
|
. "github.com/tendermint/tendermint/binary"
|
||||||
"testing"
|
"testing"
|
||||||
"fmt"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"bytes"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Distributed pseudo-exponentially to test for various cases
|
// Distributed pseudo-exponentially to test for various cases
|
||||||
@ -33,6 +33,43 @@ func TestBlock(t *testing.T) {
|
|||||||
Amount: randVar(),
|
Amount: randVar(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nameTx := &NameTx{
|
||||||
|
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
|
||||||
|
Fee: randVar(),
|
||||||
|
Name: String(randBytes(12)),
|
||||||
|
PubKey: randBytes(32),
|
||||||
|
}
|
||||||
|
|
||||||
|
txs := []Tx{}
|
||||||
|
txs = append(txs, sendTx)
|
||||||
|
txs = append(txs, nameTx)
|
||||||
|
|
||||||
|
block := &Block{
|
||||||
|
Header{
|
||||||
|
Name: "Tendermint",
|
||||||
|
Height: randVar(),
|
||||||
|
Fees: randVar(),
|
||||||
|
Time: randVar(),
|
||||||
|
PrevHash: randBytes(32),
|
||||||
|
ValidationHash: randBytes(32),
|
||||||
|
DataHash: randBytes(32),
|
||||||
|
},
|
||||||
|
Validation{
|
||||||
|
Signatures:nil,
|
||||||
|
Adjustments:nil,
|
||||||
|
},
|
||||||
|
Data{txs},
|
||||||
|
}
|
||||||
|
|
||||||
|
blockBytes := BinaryBytes(block)
|
||||||
|
block2 := ReadBlock(bytes.NewReader(blockBytes))
|
||||||
|
blockBytes2 := BinaryBytes(block2)
|
||||||
|
|
||||||
|
if !BinaryEqual(blockBytes, blockBytes2) {
|
||||||
|
t.Fatal("Write->Read of block failed.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
bondTx := &BondTx{
|
bondTx := &BondTx{
|
||||||
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
|
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
|
||||||
@ -48,16 +85,3 @@ func TestBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nameTx := &NameTx{
|
|
||||||
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
|
|
||||||
Fee: randVar(),
|
|
||||||
Name: String(randBytes(12)),
|
|
||||||
PubKey: randBytes(32),
|
|
||||||
}
|
|
||||||
|
|
||||||
txs := []Tx{}
|
|
||||||
txs = append(txs, sendTx)
|
|
||||||
txs = append(txs, nameTx)
|
|
||||||
|
|
||||||
fmt.Println(txs)
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user