package api

import (
	"encoding/json"
	"testing"
)

func TestServerPolicyJSONRoundTrip(t *testing.T) {
	in := ServerPolicy{
		MaxAgents:              128,
		LogAgentConnections:    true,
		LogShareSubmissions:    false,
		LogPoolTraffic:         true,
		StrictWalletValidation: true,
		MaxBuildSizeMB:         64,
		PoolReconnectSeconds:   30,
	}

	data, err := json.Marshal(in)
	if err != nil {
		t.Fatal(err)
	}

	var out ServerPolicy
	if err := json.Unmarshal(data, &out); err != nil {
		t.Fatal(err)
	}
	if out != in {
		t.Fatalf("round-trip mismatch:\n  got  %+v\n  want %+v", out, in)
	}
}
