Skip to content

Conversation

rynoV
Copy link
Contributor

@rynoV rynoV commented Jul 29, 2022

Closes #32

Minting testing

Minting testing

We test:

  • The cnft goes to the minter's address at first
  • The sgnft goes to the marketplace script's address
  • The cnft goes to the locking script when the sgnft is minted
  • The cnft utxo has the correct locking datum
  • The sgnft utxo has the correct marketplace datum
  • The sgnft mint tx has the correct metadata

We also test failing transactions:

  • Cnft mint does not spend correct utxo
  • Sgnft mints more than one
  • Sgnft mint does not send cnft to locking script
Buy testing

Buy Testing

For each of the below test cases, we check:

  • updated sgNft goes back to marketplace or the buyer, as determined by retBehaviour
  • marketplace does not hold the old sgNft
  • marketplace, author, and owner each get their expected shares
    • "low share" test cases mean the shares are too low to meet the min ada requirement
    • marketplace is an exception, we check that it gains its full share minus mpExpectedLoss
  • buyer lost at least buyerExpectedLoss
  • Everyone got the expected payment utxos with the expected datum
  • The tx metadata is correct

Test cases:

  ~ price too low for min ada requirement
  ~ fractional shares (.5)
  ~ fractional shares (.5), author is not seller
  ~ fractional shares (.1)
  ~ fractional shares (.1), author is not seller
  ~ fractional shares (.9)
  ~ fractional shares (.9), author is not seller
  ~ no low shares
  ~ no low shares, nft to buyer
  ~ no low shares, author is not seller
  ~ no low shares, author is not seller, nft to buyer
  ~ low marketplace share
  ~ low marketplace share, nft to buyer
  ~ low marketplace share, author is not seller
  ~ low marketplace share, author is not seller, nft to buyer
  ~ low author share
  ~ low author share, nft to buyer
  ~ low author share, author is not seller
  ~ low author share, author is not seller, nft to buyer
  ~ low author and marketplace shares
  ~ low author and marketplace shares, nft to buyer
  ~ low author and marketplace shares, author is not seller
  ~ low author and marketplace shares, author is not seller, nft to buyer

Buyer not paying full price

buyerExpectedLoss and mpExpectedLoss are defined as follows:

mpInit := Ada in the utxo holding the nft locked by the marketplace script

txFee := Buy transaction fee, in ada

price := Marketplace price of the nft

mpRemainder := mpInit - txFee

buyerExpectedLoss := price - mpRemainder

mpExpectedLoss := mpInit

For example, given the transaction 910f14c0d53e7466f5ba7ac2e3d20a51f30344ba74808aa8ebeadf143ee7a885:

2022-08-24-114638_651x453_scrot

buyerInit := 143.487861

mpInit := 1.28869

buyerOut := 130.673502

buyerExtra := 1.41368

txFee := 0.689369

buyerTotalOut := buyerOut + buyerExtra => 132.087182

buyerPaid := buyerInit - buyerTotalOut => 11.400679

price := 12

buyerAvoided := price - buyerPaid => 0.599321

mpRemainder := mpInit - txFee => 0.599321

buyerRemainder := buyerInit - buyerOut - price => 0.814359

buyerRemainder + mpRemainder => 1.41368

buyerExpectedLoss := price - mpRemainder => 11.400679

mpExpectedLoss := mpInit => 1.28869

To summarize, when the sgNft is sent to the buyer, the marketplace script ends up covering tx fees, and the remainder from the marketplace utxo goes towards funding the min ada required for the buyer's nft utxo, which leads to the buyer paying less than the full price after accounting for the nft utxo

rynoV added 2 commits July 29, 2022 16:23
Stake keys aren't provided by plutip so the mintCnft contract fails,
but the plutip test environment is working
@rynoV rynoV self-assigned this Jul 29, 2022
@rynoV rynoV linked an issue Jul 29, 2022 that may be closed by this pull request
@rynoV rynoV changed the base branch from calum/ctl-breaking-changes to master August 19, 2022 22:51
@rynoV rynoV requested a review from samuelWilliams99 August 23, 2022 00:11
We were already checking for total correct payment, but now we check
for the specific payment utxos with the correct amounts and datum
@samuelWilliams99
Copy link
Contributor

Can we get the other checks fixed? Theres some warnings about imports

Copy link
Contributor

@samuelWilliams99 samuelWilliams99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres a lot of code here that should definitely be generalised, have you spoke to the CTL guys about getting this added somewhere?

@rynoV
Copy link
Contributor Author

rynoV commented Aug 24, 2022

Can we get the other checks fixed? Theres some warnings about imports

Right now I think we have to wait for Plutonomicon/cardano-transaction-lib#906, it's making some fairly big changes that we'll need, after that I'll go through and make sure all the checks are passing

Theres a lot of code here that should definitely be generalised, have you spoke to the CTL guys about getting this added somewhere?

Just made an issue: Plutonomicon/cardano-transaction-lib#948

@rynoV rynoV marked this pull request as ready for review August 30, 2022 15:08
@rynoV
Copy link
Contributor Author

rynoV commented Aug 30, 2022

@samuelWilliams99 This should be ready for merge now. One thing though is that the plutip tests take ~15 minutes to run: https://ci.staging.mlabs.city/build/261068. For local development this isn't a big issue since you can run only some tests and skip others, but it's probably not great for CI.

I don't think there's much we can do about it right now, but if it's an issue I can make an issue and bring it up to the CTL team

@samuelWilliams99
Copy link
Contributor

Looks good to me :D

@samuelWilliams99 samuelWilliams99 merged commit 7349604 into master Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests

2 participants