Archived
2
0
This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
kerma/models/tests/mempool_test.go
2023-03-02 15:28:43 +01:00

56 lines
1.4 KiB
Go

package tests
import (
"kerma/models"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestMempool(t *testing.T) {
Convey("Given a new regular transaction", t, func() {
transaction := models.Transaction{
Type: "transaction",
Inputs: []models.Input{
{
Outpoint: models.Outpoint{
Index: 0,
Txid: "2fb7adb654b373e85c6b5c596cc110dcb6643ee138768f4aa947e9ddb7d91f8d",
},
Sig: "1bc4c05ec180932f08b95a8b5be308bb7b90c4d047720c4953440ea7cf56ba38b7e3b52ae586b594a6ae6649d8be0ae3d6944ffe9a7c5894622c33b9df276909",
},
},
Outputs: []models.Output{
{
Pubkey: "857debb2084fc8c87dec10d305993e781d9c9dbf6a81762b2f245095ae6b8fb9",
Value: 50,
},
},
}
txid := transaction.GetID()
var mempool models.Mempool
Convey("When the constructor is called with a value", func() {
mempool.Construct([]string{txid})
Convey("The value should be set", func() {
So(mempool.Type, ShouldEqual, "mempool")
So(mempool.Txids[0], ShouldEqual, txid)
})
})
Convey("When the MarshalJson is called", func() {
mempool.Construct([]string{txid})
Convey("The canonical json and no error should be returned", func() {
mempoolJSON, err := mempool.MarshalJson()
canonJSON := `{"txids":["` + txid + `"],"type":"mempool"}`
So(string(mempoolJSON), ShouldEqualJSON, canonJSON)
So(err, ShouldBeNil)
})
})
})
}