Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions wsbridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type TonnetTime struct {

type TonnetGetChallenge struct{}

type TonnetGetSessionChallenge struct{}

type TonnetChallenge struct {
Nonce []byte `tl:"int256"`
Expires int32 `tl:"int"`
Expand All @@ -65,6 +67,7 @@ func init() {
tl.Register(TonnetGetTime{}, "tonnet.getTime = tonnet.Time")
tl.Register(TonnetTime{}, "tonnet.time now:int = tonnet.Time")
tl.Register(TonnetGetChallenge{}, "tonnet.getChallenge = tonnet.Challenge")
tl.Register(TonnetGetSessionChallenge{}, "tonnet.getSessionChallenge = tonnet.Challenge")
tl.Register(TonnetChallenge{}, "tonnet.challenge nonce:int256 expires:int = tonnet.Challenge")
}

Expand Down
11 changes: 11 additions & 0 deletions wsbridge/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ func TestParseBoxedTLRejectsTrailingBytes(t *testing.T) {
}
}

func TestParseTonnetSessionChallenge(t *testing.T) {
raw := []byte{0x29, 0x3e, 0x72, 0xb3}
obj, err := parseBoxedTL(raw)
if err != nil {
t.Fatal(err)
}
if _, ok := obj.(TonnetGetSessionChallenge); !ok {
t.Fatalf("parsed %T, want TonnetGetSessionChallenge", obj)
}
}

func TestRawRPCPayloadRoundTrip(t *testing.T) {
want := []byte{1, 2, 3}
payload, err := parseRPCPayload(want, true)
Expand Down
Loading