Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,20 @@ export const data_dag_allow_spends = [
created_at: new Date("2024-01-03T10:00:00Z"),
updated_at: new Date("2024-01-03T10:00:00Z"),
},
{
hash: "allowSpendHash6",
currency_id: "currency-3",
source_addr: data_addresses[0].address,
destination_addr: data_addresses[1].address,
amount: 1500n,
fee: 8n,
last_valid_epoch_progress: 800n,
ordinal: 6n,
snapshot_hash: data_global_snapshots[1].hash,
round_id: "44444444-4444-4444-4444-444444444444",
created_at: new Date("2024-01-04T10:00:00Z"),
updated_at: new Date("2024-01-04T10:00:00Z"),
},
];

export const data_dag_spend_transactions = [
Expand Down
14 changes: 4 additions & 10 deletions src/handlers/allowSpendsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const addressAllowSpends = async (
fromCreatedAtOrdinalCursor,
{
where: {
OR: [{ source_addr: address }, { destination_addr: address }],
source_addr: address,
...ifActiveAllowSpend(event),
},
include: dagInclude,
Expand Down Expand Up @@ -390,10 +390,7 @@ export const addressAllowSpendExpirations = async (
hashCursor,
{
where: {
OR: [
{ source_addr: address },
{ dag_allow_spend: { destination_addr: address } },
],
source_addr: address,
},
include: dagInclude,
orderBy: [{ created_at: "desc" }, { hash: "asc" }],
Expand Down Expand Up @@ -487,7 +484,7 @@ export const currencyAddressAllowSpends = async (
{
where: {
metagraph_id,
OR: [{ source_addr: address }, { destination_addr: address }],
source_addr: address,
...ifActiveMetagraphAllowSpend(event),
},
include: metagraphInclude,
Expand Down Expand Up @@ -650,10 +647,7 @@ export const currencyAddressAllowSpendExpirations = async (
{
where: {
metagraph_id,
OR: [
{ source_addr: address },
{ metagraph_allow_spend: { destination_addr: address } },
],
source_addr: address,
},
include: metagraphInclude,
orderBy: [{ created_at: "desc" }, { hash: "asc" }],
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/actionsHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe("actionsHandler", () => {

expect(result.statusCode).toBe(200);
const body = validatePaginatedResponse(result);
expect(body.data.length).toBe(18);
expect(body.data.length).toBe(19);
body.data.forEach(validateAction);
});

Expand Down Expand Up @@ -122,7 +122,7 @@ describe("actionsHandler", () => {

expect(result.statusCode).toBe(200);
const body = validatePaginatedResponse(result);
expect(body.data.length).toBe(12);
expect(body.data.length).toBe(13);
body.data.forEach(validateAction);
});

Expand Down
16 changes: 8 additions & 8 deletions tests/handlers/allowSpendsHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe("AllowSpends Handler Integration Tests", () => {

expect(response.statusCode).toBe(200);
const body = validatePaginatedResponse(response);
expect(body.data.length).toBe(2);
expect(body.data.length).toBe(3);
body.data.forEach(validateDagAllowSpend);
});
});
Expand Down Expand Up @@ -199,19 +199,19 @@ describe("AllowSpends Handler Integration Tests", () => {

describe("addressAllowSpends", () => {
it("should return allow spends for a specific address", async () => {
const address = data_addresses[3].address;
const address = data_addresses[0].address;
const event = createAPIGatewayEvent({ address });

const response = await allowSpendsHandler.addressAllowSpends(event);
expect(response.statusCode).toBe(200);

const body = validatePaginatedResponse(response);
expect(body.data.length).toBe(1);
expect(body.data.length).toBe(3);
body.data.forEach(validateDagAllowSpend);
});

it("should return active only allow spends for a specific address", async () => {
const address = data_addresses[3].address;
const address = data_addresses[0].address;
const event = createAPIGatewayEvent({ address }, { active: "true" });

const response = await allowSpendsHandler.addressAllowSpends(event);
Expand Down Expand Up @@ -511,7 +511,7 @@ describe("Metagraph AllowSpends Handler Integration Tests", () => {
it("should return allow spends for an address", async () => {
const event = createAPIGatewayEvent({
metagraph_id: data_metagraphs[0].id,
address: data_addresses[1].address,
address: data_addresses[0].address,
});

const response = await allowSpendsHandler.currencyAddressAllowSpends(
Expand All @@ -525,7 +525,7 @@ describe("Metagraph AllowSpends Handler Integration Tests", () => {
const event = createAPIGatewayEvent(
{
metagraph_id: data_metagraphs[0].id,
address: data_addresses[1].address,
address: data_addresses[0].address,
},
{ active: "true" }
);
Expand All @@ -539,7 +539,7 @@ describe("Metagraph AllowSpends Handler Integration Tests", () => {
});
it("currencyAddressAllowSpendsPagination", async () => {
const metagraph_id = data_metagraphs[0].id;
const address = data_addresses[1].address;
const address = data_addresses[0].address;
await validatePaginationNext(
"1",
{ metagraph_id, address },
Expand All @@ -552,7 +552,7 @@ describe("Metagraph AllowSpends Handler Integration Tests", () => {
it("should return spend transactions for an address", async () => {
const event = createAPIGatewayEvent({
metagraph_id: data_dag_spend_transactions[1].currency_id,
address: data_addresses[1].address,
address: data_addresses[0].address,
});

const response =
Expand Down