bond to override lock limit
This commit is contained in:
@@ -615,6 +615,7 @@ describe("P2PIX", () => {
|
||||
price,
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const fail2 = p2pix.lock(
|
||||
zero,
|
||||
@@ -622,6 +623,7 @@ describe("P2PIX", () => {
|
||||
price,
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
|
||||
expect(fail).to.be.revertedWithCustomError(
|
||||
@@ -651,6 +653,7 @@ describe("P2PIX", () => {
|
||||
price * 2n,
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
|
||||
await expect(fail).to.be.revertedWithCustomError(
|
||||
@@ -676,6 +679,7 @@ describe("P2PIX", () => {
|
||||
1000n,
|
||||
[ethers.keccak256(ethers.toUtf8Bytes("wrong"))],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
|
||||
await expect(fail).to.be.revertedWithCustomError(
|
||||
@@ -703,6 +707,7 @@ describe("P2PIX", () => {
|
||||
price * 2n,
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
|
||||
await expect(fail).to.be.revertedWithCustomError(
|
||||
@@ -710,6 +715,42 @@ describe("P2PIX", () => {
|
||||
P2PixErrors.AmountNotAllowed,
|
||||
);
|
||||
});
|
||||
it("should override spend limit if buyer pays the bond", async () => {
|
||||
await erc20.approve(
|
||||
p2pix.address,
|
||||
price.mul(3),
|
||||
);
|
||||
await p2pix.deposit(
|
||||
"1",
|
||||
merkleRoot,
|
||||
erc20.address,
|
||||
price.mul(3),
|
||||
true,
|
||||
);
|
||||
await erc20
|
||||
.transfer(
|
||||
acc02.address,
|
||||
price,
|
||||
);
|
||||
await erc20
|
||||
.connect(acc02)
|
||||
.approve(
|
||||
p2pix.address,
|
||||
price.mul(30000),
|
||||
);
|
||||
const bond = p2pix
|
||||
.connect(acc02)
|
||||
.lock(
|
||||
owner.address,
|
||||
erc20.address,
|
||||
price.mul(2),
|
||||
[],
|
||||
[],
|
||||
true,
|
||||
);
|
||||
|
||||
await expect(bond).to.be.ok;
|
||||
});
|
||||
it("should create a lock, update storage and emit events via the allowlist path", async () => {
|
||||
const target = "333";
|
||||
await erc20.approve(p2pix.target, price);
|
||||
@@ -728,6 +769,7 @@ describe("P2PIX", () => {
|
||||
price,
|
||||
proof,
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const storage: Lock = await p2pix.mapLocks.staticCall(
|
||||
1,
|
||||
@@ -772,6 +814,7 @@ describe("P2PIX", () => {
|
||||
price,
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const storage: Lock = await p2pix.mapLocks.staticCall(
|
||||
1,
|
||||
@@ -831,6 +874,7 @@ describe("P2PIX", () => {
|
||||
price,
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
await p2pix
|
||||
.connect(acc01)
|
||||
@@ -847,6 +891,7 @@ describe("P2PIX", () => {
|
||||
price + 1n,
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const storage: Lock = await p2pix.mapLocks.staticCall(
|
||||
2,
|
||||
@@ -897,6 +942,7 @@ describe("P2PIX", () => {
|
||||
newPrice,
|
||||
proof,
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const storage1: Lock = await p2pix.mapLocks.staticCall(
|
||||
1,
|
||||
@@ -913,6 +959,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const storage2: Lock = await p2pix.mapLocks.staticCall(
|
||||
2,
|
||||
@@ -929,6 +976,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const storage3: Lock = await p2pix.mapLocks.staticCall(
|
||||
3,
|
||||
@@ -1205,6 +1253,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const lockID = BigInt(1);
|
||||
await mine(13);
|
||||
@@ -1246,6 +1295,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const lockID = BigInt(1);
|
||||
await p2pix.release(
|
||||
@@ -1290,6 +1340,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
|
||||
await p2pix
|
||||
@@ -1307,6 +1358,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const fail = p2pix
|
||||
.connect(acc01)
|
||||
@@ -1348,6 +1400,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const fail = p2pix
|
||||
.connect(acc01)
|
||||
@@ -1404,6 +1457,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const acc01Key = await p2pix._castAddrToKey.staticCall(
|
||||
acc01.address,
|
||||
@@ -1568,6 +1622,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
await p2pix
|
||||
.connect(acc03)
|
||||
@@ -1577,6 +1632,7 @@ describe("P2PIX", () => {
|
||||
BigInt(50),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
await p2pix
|
||||
.connect(acc03)
|
||||
@@ -1586,6 +1642,7 @@ describe("P2PIX", () => {
|
||||
BigInt(25),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
|
||||
const lockStatus1 =
|
||||
@@ -1755,6 +1812,7 @@ describe("P2PIX", () => {
|
||||
BigInt(1),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const lockID = BigInt(1);
|
||||
const fail = p2pix.unlockExpired([lockID]);
|
||||
@@ -1793,6 +1851,7 @@ describe("P2PIX", () => {
|
||||
BigInt(1),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const lockID = BigInt(1);
|
||||
// await mine(10);
|
||||
@@ -1826,6 +1885,7 @@ describe("P2PIX", () => {
|
||||
BigInt(1),
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const lockID = BigInt(1);
|
||||
await mine(11);
|
||||
@@ -1889,6 +1949,7 @@ describe("P2PIX", () => {
|
||||
price,
|
||||
proof,
|
||||
[],
|
||||
false,
|
||||
);
|
||||
// as return values of non view functions can't be accessed
|
||||
// outside the evm, we fetch the lockID from the emitted event.
|
||||
@@ -1928,6 +1989,7 @@ describe("P2PIX", () => {
|
||||
BigInt(100),
|
||||
[],
|
||||
[lockID],
|
||||
false
|
||||
);
|
||||
const remaining = await p2pix.getBalance.staticCall(
|
||||
owner.address,
|
||||
@@ -1961,6 +2023,7 @@ describe("P2PIX", () => {
|
||||
price,
|
||||
proof,
|
||||
[],
|
||||
false,
|
||||
);
|
||||
const lockID = BigInt(1);
|
||||
// mine blocks to expire lock
|
||||
|
||||
Reference in New Issue
Block a user