func TestAdditionalData(t *testing.T) {
	t.Parallel()
	db, cleanup := newTestDB(t)
	defer cleanup()
	a := &account.Account{
		Value:         btcutil.SatoshiPerBitcoin,
		Expiry:        1337,
		TraderKey:     testTraderKeyDesc,
		AuctioneerKey: testAuctioneerKey,
		BatchKey:      testBatchKey,
		Secret:        sharedSecret,
		State:         account.StateInitiated,
		HeightHint:    1,
	}
	if err := db.AddAccount(a); err != nil {
		t.Fatalf("unable to add account: %v", err)
	}
	assertAccountExists(t, db, a)
	accountKey := getAccountKey(a)
	myAdditionalValue := uint32(0)
	require.NoError(t, db.DB.View(func(tx *bbolt.Tx) error {
		subBucket, err := getAdditionalDataBucket(
			tx.Bucket(accountBucketKey), accountKey, false,
		)
		if err != nil {
			return err
		}
		return readAdditionalValue(
			subBucket, additionalDataKeyTest, &myAdditionalValue,
			additionalDataTestDefaultValue,
		)
	}))
	require.Equal(t, additionalDataTestDefaultValue, myAdditionalValue)
	require.NoError(t, db.DB.Update(func(tx *bbolt.Tx) error {
		subBucket, err := getAdditionalDataBucket(
			tx.Bucket(accountBucketKey), accountKey, true,
		)
		if err != nil {
			return err
		}
		return writeAdditionalValue(
			subBucket, additionalDataKeyTest, uint32(6543),
		)
	}))
	require.NoError(t, db.DB.View(func(tx *bbolt.Tx) error {
		subBucket, err := getAdditionalDataBucket(
			tx.Bucket(accountBucketKey), accountKey, false,
		)
		if err != nil {
			return err
		}
		return readAdditionalValue(
			subBucket, additionalDataKeyTest, &myAdditionalValue,
			additionalDataTestDefaultValue,
		)
	}))
	require.Equal(t, uint32(6543), myAdditionalValue)
	require.Error(t, db.DB.View(func(tx *bbolt.Tx) error {
		subBucket, err := getAdditionalDataBucket(
			tx.Bucket(accountBucketKey), accountKey, false,
		)
		if err != nil {
			return err
		}
		return readAdditionalValue(
			subBucket, additionalDataKeyTest, &myAdditionalValue,
			uint64(additionalDataTestDefaultValue),
		)
	}))
}
TestAdditionalData tests that the functionality of adding additional data to
a sub bucket works as expected.
package clientdb
import (
	"testing"
	"github.com/btcsuite/btcutil"
	"github.com/lightninglabs/pool/account"
	"github.com/stretchr/testify/require"
	"go.etcd.io/bbolt"
)
var (
	additionalDataKeyTest = []byte("key-test")
)
const (
	additionalDataTestDefaultValue uint32 = 144 * 7
)