tendermint/blocks/block_test.go

64 lines
1.4 KiB
Go
Raw Normal View History

2014-06-05 02:34:45 -07:00
package blocks
import (
. "github.com/tendermint/tendermint/binary"
"testing"
"fmt"
"math/rand"
)
// Distributed pseudo-exponentially to test for various cases
func randVar() UInt64 {
bits := rand.Uint32() % 64
if bits == 0 { return 0 }
n := uint64(1 << (bits-1))
n += uint64(rand.Int63()) & ((1 << (bits-1)) - 1)
return UInt64(n)
}
func randBytes(n int) ByteSlice {
bs := make([]byte, n)
for i:=0; i<n; i++ {
bs[i] = byte(rand.Intn(256))
}
return bs
}
func TestBlock(t *testing.T) {
sendTx := &SendTx{
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
Fee: randVar(),
To: AccountNumber(randVar()),
Amount: randVar(),
}
2014-06-05 11:04:56 -07:00
/*
2014-06-05 02:34:45 -07:00
bondTx := &BondTx{
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
Fee: randVar(),
UnbondTo: AccountNumber(randVar()),
Amount: randVar(),
}
unbondTx := &UnbondTx{
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
Fee: randVar(),
Amount: randVar(),
}
2014-06-05 11:04:56 -07:00
*/
2014-06-05 02:34:45 -07:00
nameTx := &NameTx{
Signature: Signature{AccountNumber(randVar()), randBytes(32)},
Fee: randVar(),
Name: String(randBytes(12)),
PubKey: randBytes(32),
}
2014-06-05 11:04:56 -07:00
txs := []Tx{}
txs = append(txs, sendTx)
txs = append(txs, nameTx)
2014-06-05 02:34:45 -07:00
2014-06-05 11:04:56 -07:00
fmt.Println(txs)
2014-06-05 02:34:45 -07:00
}