func assertReadableBlockHeader(t *testing.T, rb ReadableBlockHeader,
	bh coin.BlockHeader) {
	assert.Equal(t, rb.Version, bh.Version)
	assert.Equal(t, rb.Time, bh.Time)
	assert.Equal(t, rb.BkSeq, bh.BkSeq)
	assert.Equal(t, rb.Fee, bh.Fee)
	assert.NotPanics(t, func() {
		assert.Equal(t, coin.MustSHA256FromHex(rb.PrevHash), bh.PrevHash)
		assert.Equal(t, coin.MustSHA256FromHex(rb.BodyHash), bh.BodyHash)
	})
	assertJSONSerializability(t, &rb)
}
func assertReadableTransactionHeader(t *testing.T,
	rth ReadableTransactionHeader, th coin.TransactionHeader) {
	assert.Equal(t, len(rth.Sigs), len(th.Sigs))
	assert.NotPanics(t, func() {
		for i, s := range rth.Sigs {
			assert.Equal(t, coin.MustSigFromHex(s), th.Sigs[i])
		}
		assert.Equal(t, coin.MustSHA256FromHex(rth.Hash), th.Hash)
	})
	assertJSONSerializability(t, &rth)
}
Example #3
0
func NewDeterministicWalletFromReadable(r *ReadableWallet) Wallet {
	if r.Type != DeterministicWalletType {
		log.Panic("ReadableWallet type must be Deterministic")
	}
	if len(r.Entries) != 1 {
		log.Panic("Deterministic wallets have exactly 1 entry")
	}
	seed := coin.MustSHA256FromHex(r.Extra["seed"].(string))
	return &DeterministicWallet{
		Filename: r.Filename,
		Name:     r.Name,
		Entry:    r.Entries.ToWalletEntries().ToArray()[0],
		Seed:     DeterministicWalletSeed(seed),
	}
}
func assertReadableTransactionInput(t *testing.T, rti string, ti coin.SHA256) {
	assert.NotPanics(t, func() {
		assert.Equal(t, coin.MustSHA256FromHex(rti), ti)
	})
	assertJSONSerializability(t, &rti)
}