mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-09-14 21:40:11 +00:00

* [NOD-1223] Move all network stuff into a new network package. * [NOD-1223] Delete the unused package testutil. * [NOD-1223] Move infrastructure stuff into a new instrastructure package. * [NOD-1223] Move domain stuff into a new domain package.
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Copyright (c) 2017 The btcsuite developers
|
|
// Copyright (c) 2017 The Decred developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package model_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/kaspanet/kaspad/network/rpc/model"
|
|
)
|
|
|
|
// TestRPCServerWebsocketResults ensures any results that have custom marshalling
|
|
// work as intended.
|
|
func TestRPCServerWebsocketResults(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
result interface{}
|
|
expected string
|
|
}{
|
|
{
|
|
name: "RescannedBlock",
|
|
result: &model.RescannedBlock{
|
|
Hash: "blockhash",
|
|
Transactions: []string{"serializedtx"},
|
|
},
|
|
expected: `{"hash":"blockhash","transactions":["serializedtx"]}`,
|
|
},
|
|
}
|
|
|
|
t.Logf("Running %d tests", len(tests))
|
|
for i, test := range tests {
|
|
marshalled, err := json.Marshal(test.result)
|
|
if err != nil {
|
|
t.Errorf("Test #%d (%s) unexpected error: %v", i,
|
|
test.name, err)
|
|
continue
|
|
}
|
|
if string(marshalled) != test.expected {
|
|
t.Errorf("Test #%d (%s) unexpected marhsalled data - "+
|
|
"got %s, want %s", i, test.name, marshalled,
|
|
test.expected)
|
|
continue
|
|
}
|
|
}
|
|
}
|