func TestSerializeLocalBatchSnapshot(t *testing.T) {
	for idx, testSnapshot := range allSnapshots {
		pre := testSnapshot
		t.Run(fmt.Sprintf("snapshot-%d", idx), func(t *testing.T) {
			t.Parallel()
			buf := bytes.Buffer{}
			if err := serializeLocalBatchSnapshot(&buf, pre); err != nil {
				t.Fatal(err)
			}
			post, err := deserializeLocalBatchSnapshot(&buf)
			if err != nil {
				t.Fatal(err)
			}
			require.Equal(t, pre, post)
		})
	}
}
TestSerializeLocalBatchSnapshot checks that (de)serialization of local batch
snapshots works as expected.
package clientdb
import (
	"bytes"
	"fmt"
	"net"
	"reflect"
	"testing"
	"github.com/btcsuite/btcutil"
	"github.com/davecgh/go-spew/spew"
	"github.com/lightninglabs/pool/account"
	"github.com/lightninglabs/pool/order"
	"github.com/lightninglabs/pool/terms"
	"github.com/stretchr/testify/require"
	"go.etcd.io/bbolt"
)
var (
	testAccount = &account.Account{
		Value:         btcutil.SatoshiPerBitcoin,
		Expiry:        1337,
		TraderKey:     testTraderKeyDesc,
		AuctioneerKey: testAuctioneerKey,
		BatchKey:      testBatchKey,
		Secret:        sharedSecret,
		State:         account.StateInitiated,
		HeightHint:    1,
	}
	testNonce1 = order.Nonce([32]byte{1, 1, 1})
	testNonce2 = order.Nonce([32]byte{2, 2, 2})
	testDuration uint32 = 144
	testAccounts = map[[33]byte]*account.Account{
		testRawTraderKeyArr: testAccount,
	}
	testOrders = map[order.Nonce]order.Order{
		testNonce1: &order.Bid{
			Kit: *newOrderKit(testNonce1, testDuration),
		},
		testNonce2: &order.Ask{
			Kit: *newOrderKit(testNonce2, testDuration),
		},
	}
	testMatchedOrders = map[order.Nonce][]*order.MatchedOrder{
		testNonce1: {
			{
				Order: &order.Ask{
					Kit: *dummyOrder(50000, 2048),
				},
				MultiSigKey: [33]byte{1, 2, 3},
				NodeKey:     [33]byte{1, 2, 3},
				NodeAddrs: []net.Addr{
					&net.TCPAddr{
						IP: net.IP{
							0x12, 0x34, 0x56, 0x78,
						},
						Port: 8080,
					},
				},
				UnitsFilled: 19,
			},
			{
				Order: &order.Ask{
					Kit: *dummyOrder(50000, 2048),
				},
				MultiSigKey: [33]byte{2, 2, 3},
				NodeKey:     [33]byte{2, 2, 3},
				NodeAddrs: []net.Addr{
					&net.TCPAddr{
						IP: net.IP{
							0x12, 0x34, 0x56, 0x78,
						},
						Port: 8080,
					},
				},
				UnitsFilled: 10,
			},
		},
		testNonce2: {
			{
				Order: &order.Bid{
					Kit: *dummyOrder(50000, 144),
				},
				MultiSigKey: [33]byte{1, 2, 3},
				NodeKey:     [33]byte{1, 2, 3},
				NodeAddrs: []net.Addr{
					&net.TCPAddr{
						IP: net.IP{
							0x12, 0x34, 0x56, 0x78,
						},
						Port: 8080,
					},
				},
				UnitsFilled: 100,
			},
			{
				Order: &order.Bid{
					Kit: *dummyOrder(50000, 2048),
				},
				MultiSigKey: [33]byte{2, 2, 3},
				NodeKey:     [33]byte{2, 2, 3},
				NodeAddrs: []net.Addr{
					&net.TCPAddr{
						IP: net.IP{
							0x12, 0x34, 0x56, 0x78,
						},
						Port: 8080,
					},
				},
				UnitsFilled: 10,
			},
		},
	}
	testSnapshot = &LocalBatchSnapshot{
		Version: order.DefaultBatchVersion,
		BatchID: testBatchID,
		ClearingPrices: map[uint32]order.FixedRatePremium{
			testDuration:     999,
			testDuration * 2: 1234,
		},
		ExecutionFee:   *terms.NewLinearFeeSchedule(101, 900),
		BatchTX:        testBatchTx,
		BatchTxFeeRate: 123456,
		Accounts:       testAccounts,
		Orders:         testOrders,
		MatchedOrders:  testMatchedOrders,
	}
	allSnapshots = []*LocalBatchSnapshot{
		testSnapshot,
		{
			Version: order.DefaultBatchVersion,
			BatchID: testBatchID,
			ClearingPrices: map[uint32]order.FixedRatePremium{
				order.LegacyLeaseDurationBucket: 999,
			},
			ExecutionFee:   *terms.NewLinearFeeSchedule(101, 900),
			BatchTX:        testBatchTx,
			BatchTxFeeRate: 123456,
			Accounts:       testAccounts,
			Orders:         testOrders,
			MatchedOrders:  testMatchedOrders,
		},
	}
)
func newOrderKit(nonce order.Nonce, duration uint32) *order.Kit {
	kit := order.NewKit(nonce)
	kit.LeaseDuration = duration
	return kit
}