tu-wien
/
kerma
Archived
2
0
Fork 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/chaintip_test.go

37 lines
878 B
Go

package tests
import (
"kerma/models"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestChaintip(t *testing.T) {
Convey("Given a new chaintip", t, func() {
blockID := models.GetGenesisBlock().GetID()
var chaintip models.Chaintip
Convey("When the constructor is called with a value", func() {
chaintip.Construct(blockID)
Convey("The value should be set", func() {
So(chaintip.Type, ShouldEqual, "chaintip")
So(chaintip.BlockID, ShouldEqual, blockID)
})
})
Convey("When the MarshalJson is called", func() {
chaintip.Construct(blockID)
Convey("The canonical json and no error should be returned", func() {
chaintipJSON, err := chaintip.MarshalJson()
canonJSON := `{"blockid":"` + blockID + `","type":"chaintip"}`
So(string(chaintipJSON), ShouldEqualJSON, canonJSON)
So(err, ShouldBeNil)
})
})
})
}