Skip to content

Commit d283dcf

Browse files
committed
Add test cases for blueprint localstate query api examples
1 parent b1d5a04 commit d283dcf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

protocol/localstatequery/messages_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ package localstatequery
1616

1717
import (
1818
"encoding/hex"
19+
"fmt"
20+
"os"
1921
"reflect"
2022
"testing"
2123

@@ -92,6 +94,16 @@ var tests = []testDefinition{
9294
Message: NewMsgReAcquireVolatileTip(),
9395
MessageType: MessageTypeReacquireVolatileTip,
9496
},
97+
{
98+
CborHex: string(readFile("../../cardano-blueprint/src/api/examples/getSystemStart/query.cbor")),
99+
Message: NewMsgQuery(&SystemStartQuery{simpleQueryBase{Type: QueryTypeSystemStart}}),
100+
MessageType: MessageTypeQuery,
101+
},
102+
{
103+
CborHex: string(readFile("../../cardano-blueprint/src/api/examples/getSystemStart/result.cbor")),
104+
Message: NewMsgResult([]byte{5}), // FIXME: not correct and should also check SystemStart decoder
105+
MessageType: MessageTypeResult,
106+
},
95107
}
96108

97109
func TestDecode(t *testing.T) {
@@ -135,3 +147,12 @@ func TestEncode(t *testing.T) {
135147
}
136148
}
137149
}
150+
151+
// Helper function to allow inline reading of a file without capturing the error
152+
func readFile(path string) []byte {
153+
data, err := os.ReadFile(path)
154+
if err != nil {
155+
panic(fmt.Sprintf("error reading file: %s", err))
156+
}
157+
return data
158+
}

0 commit comments

Comments
 (0)