rpcserver+order: make batch version configurable

This commit is contained in:
Oliver Gugger 2021-12-21 14:35:33 +01:00
parent 1f50c7839a
commit e52b1ff5a6
No known key found for this signature in database
GPG key ID: 8E4256593F177720
3 changed files with 17 additions and 7 deletions

View file

@ -79,6 +79,10 @@ type ManagerConfig struct {
// Signer is used to sign orders before submitting them to the server.
Signer lndclient.SignerClient
// BatchVersion is the batch version that we should use to verify new
// batches against.
BatchVersion BatchVersion
}
// manager is responsible for the management of orders.
@ -138,7 +142,7 @@ func (m *manager) Start() error {
getAccount: m.cfg.AcctStore.Account,
wallet: m.cfg.Wallet,
ourNodePubkey: m.ourNodeInfo.IdentityPubkey,
version: CurrentBatchVersion,
version: m.cfg.BatchVersion,
}
m.batchSigner = &batchSigner{
getAccount: m.cfg.AcctStore.Account,

View file

@ -24,7 +24,8 @@ func TestValidateOrderAccountIsolation(t *testing.T) {
orderStore := newMockStore()
orderManager := NewManager(&ManagerConfig{
Store: orderStore,
Store: orderStore,
BatchVersion: CurrentBatchVersion,
})
// We'll now create two accounts, one that's 1 BTC in size, while the
@ -109,7 +110,8 @@ func TestValidateOrder(t *testing.T) {
orderStore := newMockStore()
orderManager := NewManager(&ManagerConfig{
Store: orderStore,
Store: orderStore,
BatchVersion: CurrentBatchVersion,
})
// We'll now create an account with sufficient size.
@ -266,10 +268,11 @@ func TestPrepareOrderSidecarTicket(t *testing.T) {
mockLightning := test.NewMockLightning()
mockSigner := test.NewMockSigner()
mgr := NewManager(&ManagerConfig{
AcctStore: &mockAccountStore{},
Wallet: test.NewMockWalletKit(),
Lightning: mockLightning,
Signer: mockSigner,
AcctStore: &mockAccountStore{},
Wallet: test.NewMockWalletKit(),
Lightning: mockLightning,
Signer: mockSigner,
BatchVersion: CurrentBatchVersion,
})
require.NoError(t, mgr.Start())
defer mgr.Stop()

View file

@ -117,6 +117,9 @@ func newRPCServer(server *Server) *rpcServer {
Lightning: lndServices.Client,
Wallet: lndServices.WalletKit,
Signer: lndServices.Signer,
BatchVersion: order.BatchVersion(
server.cfg.DebugConfig.BatchVersion,
),
}),
marshaler: NewMarshaler(&marshalerConfig{
GetOrders: server.db.GetOrders,