Skip to content

Commit

Permalink
double check inputs order preserving
Browse files Browse the repository at this point in the history
  • Loading branch information
arobsn committed Sep 16, 2024
1 parent a08a573 commit da29dd7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/core/src/builder/transactionBuilder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
RECOMMENDED_MIN_FEE_VALUE,
TransactionBuilder
} from "./transactionBuilder";
import { mockUTxO } from "packages/mock-chain/src";

const height = 844540;
const a1 = {
Expand Down Expand Up @@ -818,16 +819,19 @@ describe("Building", () => {
}
});

it("Should ensure inclusion and order or inputs", () => {
it("Should ensure inclusion and preserver the order or inputs", () => {
const anotherInput = mockUTxO({ ergoTree: a1.ergoTree });
const transaction = new TransactionBuilder(height)
.from(regularBoxes)
.and.from(manyTokensBoxes, { ensureInclusion: true })
.from(manyTokensBoxes, { ensureInclusion: true })
.and.from(regularBoxes)
.and.from(anotherInput, { ensureInclusion: true })
.sendChangeTo(a1.address)
.build();

expect(transaction.inputs).to.have.length(manyTokensBoxes.length);
const expectedInputs = [...manyTokensBoxes, anotherInput];
expect(transaction.inputs).to.have.length(expectedInputs.length);
for (let i = 0; i < transaction.inputs.length; i++) {
expect(transaction.inputs[i].boxId).to.be.equal(manyTokensBoxes[i].boxId);
expect(transaction.inputs[i].boxId).to.be.equal(expectedInputs[i].boxId);
}
});

Expand Down

0 comments on commit da29dd7

Please sign in to comment.