-
Notifications
You must be signed in to change notification settings - Fork 42
ApproveAndCall return values #527
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,6 +443,31 @@ describe("VendingMachine", async function() { | |
expect(eventList[0].returnValues._digest).to.equal(sighash) | ||
}) | ||
|
||
it("returns true on success", async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couple of things here:
Same note below for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes In a way. In order to test The tests themselves are testing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I believe we should add isolated tests to contract-related test suites like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I should have made my point clearer: this test is entirely a test of In the interest of keeping things moving I'm going to merge this as-is, since it implements the underlying functionality we're looking for---but let's strive to make the changes quickly unless there was a good reason to have it in the current structure. |
||
await testDeposit.setState(states.ACTIVE) | ||
await tbtcDepositToken.forceMint(vendingMachine.address, tdtId) | ||
await tbtcToken.forceMint(owner, depositValue.add(signerFee)) | ||
await feeRebateToken.forceMint(owner, tdtId) | ||
const tbtcToBtc = vendingMachine.abi.filter( | ||
x => x.name == "tbtcToBtc", | ||
)[0] | ||
const calldata = web3.eth.abi.encodeFunctionCall(tbtcToBtc, [ | ||
testDeposit.address, | ||
"0x1111111100000000", | ||
redeemerOutputScript, | ||
owner, | ||
]) | ||
|
||
const success = await tbtcToken.approveAndCall.call( | ||
redemptionScript.address, | ||
depositValue.add(signerFee), | ||
calldata, | ||
{from: owner}, | ||
) | ||
|
||
expect(success).to.equal(true) | ||
}) | ||
|
||
it("reverts for unknown function calls encoded in _extraData", async () => { | ||
const unknownFunctionSignature = "0xCAFEBABE" | ||
await tbtcToken.forceMint(owner, depositValue.add(signerFee)) | ||
|
@@ -514,6 +539,35 @@ describe("VendingMachine", async function() { | |
expect(await feeRebateToken.ownerOf(tdtId)).to.equal(owner) | ||
}) | ||
|
||
it("reverts true on success", async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const unqualifiedDepositToTbtcABI = vendingMachine.abi.filter( | ||
x => x.name == "unqualifiedDepositToTbtc", | ||
)[0] | ||
const calldata = web3.eth.abi.encodeFunctionCall( | ||
unqualifiedDepositToTbtcABI, | ||
[ | ||
testDeposit.address, | ||
_version, | ||
_txInputVector, | ||
_txOutputVector, | ||
_txLocktime, | ||
_fundingOutputIndex, | ||
_merkleProof, | ||
_txIndexInBlock, | ||
_bitcoinHeaders, | ||
], | ||
) | ||
|
||
const success = await tbtcDepositToken.approveAndCall.call( | ||
fundingScript.address, | ||
tdtId, | ||
calldata, | ||
{from: owner}, | ||
) | ||
|
||
expect(success).to.be.true | ||
}) | ||
|
||
it("reverts for unknown function calls encoded in _extraData", async () => { | ||
const unknownFunctionSignature = "0xCAFEBABE" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure seems different---do we need to introduce the same
if (approve...)
guard to the TDT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approve()
does notreturn bool
for ERC721There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍