Add compatibility aliases documented in specs but missing from code: - node: NewNodeManagerWithPaths, NewPeerRegistryWithPath (deprecated constructor aliases), RegisterWithTransport (deprecated method alias), ConnectedPeers (count alias), GetLogsPayload (type alias) - levin: Short-form Value constructors (Uint64Val, StringVal, ObjectVal, etc.) matching spec naming - logging: WithComponent, GetLevel, GetGlobal (deprecated method aliases) - ueps: TagCurrentLay, TagTargetLay (short-form tag constant aliases) All aliases delegate to the canonical AX-compliant names. Tests cover every alias with round-trip verification where applicable. Co-Authored-By: Virgil <virgil@lethean.io>
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package node
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewNodeManagerWithPaths_Good(t *testing.T) {
|
|
keyPath := t.TempDir() + "/private.key"
|
|
configPath := t.TempDir() + "/node.json"
|
|
|
|
nm, err := NewNodeManagerWithPaths(keyPath, configPath)
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, nm)
|
|
assert.False(t, nm.HasIdentity(), "fresh manager should have no identity")
|
|
}
|
|
|
|
func TestNewPeerRegistryWithPath_Good(t *testing.T) {
|
|
peersPath := t.TempDir() + "/peers.json"
|
|
|
|
pr, err := NewPeerRegistryWithPath(peersPath)
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, pr)
|
|
assert.Equal(t, 0, pr.Count())
|
|
pr.Close()
|
|
}
|
|
|
|
func TestGetLogsPayload_Good(t *testing.T) {
|
|
var payload GetLogsPayload
|
|
payload.MinerName = "xmrig-0"
|
|
payload.Lines = 100
|
|
payload.Since = 1234567890
|
|
|
|
var request LogsRequestPayload = payload
|
|
assert.Equal(t, "xmrig-0", request.MinerName)
|
|
assert.Equal(t, 100, request.Lines)
|
|
assert.Equal(t, int64(1234567890), request.Since)
|
|
}
|
|
|
|
func TestTransportConnectedPeers_Good(t *testing.T) {
|
|
keyPath := t.TempDir() + "/private.key"
|
|
configPath := t.TempDir() + "/node.json"
|
|
peersPath := t.TempDir() + "/peers.json"
|
|
|
|
nm, err := NewNodeManagerFromPaths(keyPath, configPath)
|
|
require.NoError(t, err)
|
|
|
|
pr, err := NewPeerRegistryFromPath(peersPath)
|
|
require.NoError(t, err)
|
|
defer pr.Close()
|
|
|
|
transport := NewTransport(nm, pr, DefaultTransportConfig())
|
|
assert.Equal(t, transport.ConnectedPeerCount(), transport.ConnectedPeers())
|
|
assert.Equal(t, 0, transport.ConnectedPeers())
|
|
}
|