mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
multi: add UpdateAccountAliasForTests query
In the upcoming kvdb to SQL migration of the actions store, we need to simulate in tests that two or more accounts have colliding account aliases for the first 4 bytes of the alias. In order to allow creation of such accounts, we need to be able to update the alias of an account in tests, and this commit adds the a SQL query enabling this functionality. Note that the `UpdateAccountAliasForTests` query is only intended for use in tests and should not be used in production code.
This commit is contained in:
parent
5d8f03e241
commit
4ccb56a771
4 changed files with 32 additions and 0 deletions
|
|
@ -49,6 +49,9 @@ type SQLQueries interface {
|
|||
UpdateAccountBalance(ctx context.Context, arg sqlc.UpdateAccountBalanceParams) (int64, error)
|
||||
UpdateAccountExpiry(ctx context.Context, arg sqlc.UpdateAccountExpiryParams) (int64, error)
|
||||
UpdateAccountLastUpdate(ctx context.Context, arg sqlc.UpdateAccountLastUpdateParams) (int64, error)
|
||||
// UpdateAccountAliasForTests is a query intended only for testing
|
||||
// purposes, to change the account alias.
|
||||
UpdateAccountAliasForTests(ctx context.Context, arg sqlc.UpdateAccountAliasForTestsParams) (int64, error)
|
||||
UpsertAccountPayment(ctx context.Context, arg sqlc.UpsertAccountPaymentParams) error
|
||||
GetAccountInvoice(ctx context.Context, arg sqlc.GetAccountInvoiceParams) (sqlc.AccountInvoice, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,6 +313,26 @@ func (q *Queries) SetAccountIndex(ctx context.Context, arg SetAccountIndexParams
|
|||
return err
|
||||
}
|
||||
|
||||
const updateAccountAliasForTests = `-- name: UpdateAccountAliasForTests :one
|
||||
UPDATE accounts
|
||||
SET alias = $1
|
||||
WHERE id = $2
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
type UpdateAccountAliasForTestsParams struct {
|
||||
Alias int64
|
||||
ID int64
|
||||
}
|
||||
|
||||
// NOTE: This query is only intended for testing purposes.
|
||||
func (q *Queries) UpdateAccountAliasForTests(ctx context.Context, arg UpdateAccountAliasForTestsParams) (int64, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateAccountAliasForTests, arg.Alias, arg.ID)
|
||||
var id int64
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
||||
const updateAccountBalance = `-- name: UpdateAccountBalance :one
|
||||
UPDATE accounts
|
||||
SET current_balance_msat = $1
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ type Querier interface {
|
|||
SetSessionGroupID(ctx context.Context, arg SetSessionGroupIDParams) error
|
||||
SetSessionRemotePublicKey(ctx context.Context, arg SetSessionRemotePublicKeyParams) error
|
||||
SetSessionRevokedAt(ctx context.Context, arg SetSessionRevokedAtParams) error
|
||||
// NOTE: This query is only intended for testing purposes.
|
||||
UpdateAccountAliasForTests(ctx context.Context, arg UpdateAccountAliasForTestsParams) (int64, error)
|
||||
UpdateAccountBalance(ctx context.Context, arg UpdateAccountBalanceParams) (int64, error)
|
||||
UpdateAccountExpiry(ctx context.Context, arg UpdateAccountExpiryParams) (int64, error)
|
||||
UpdateAccountLastUpdate(ctx context.Context, arg UpdateAccountLastUpdateParams) (int64, error)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,13 @@ RETURNING id;
|
|||
INSERT INTO account_invoices (account_id, hash)
|
||||
VALUES ($1, $2);
|
||||
|
||||
-- name: UpdateAccountAliasForTests :one
|
||||
-- NOTE: This query is only intended for testing purposes.
|
||||
UPDATE accounts
|
||||
SET alias = $1
|
||||
WHERE id = $2
|
||||
RETURNING id;
|
||||
|
||||
-- name: DeleteAccountPayment :exec
|
||||
DELETE FROM account_payments
|
||||
WHERE hash = $1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue