geniusyield / atlas

Application backend for Plutus smart contracts on Cardano
https://atlas-app.io
Apache License 2.0
60 stars 15 forks source link

Unknown source of extra Lovelace after unit test run #282

Open Fiftyw3bs opened 5 months ago

Fiftyw3bs commented 5 months ago

Describe the bug

My test uses withWalletBalancesCheckSimple to validate the wallet balance after submitting transaction:

withWalletBalancesCheckSimple [w1 := valueSingleton
      ( case
            cAssetClass
          of
            Left _ -> GYLovelace
            Right x -> x
      ) 1 <> valueNegate (valueSingleton fakeGold 100) ] $ do mintOwnerTokenRun cSettings c

But I get the following result with an extra 1667970 lovelace

[error] Generic fail: Wallet: w1. 

Old balance: 1000000 02384095adfb494c4d3b53fad4fc44ce2da4db629c50cf627901b804.476f6c64 + 1000000 01f0ef87e344b733286dfce55cfd7e10c90b57a3b1825c984454ce6a.49726f6e + 1000000000000 lovelace. 

New balance: 1 569c5e8498ee05e8651ad68b6c81f9756852e218933db722ebc72b90.436f6c6f6e794f776e6572 + 999900 02384095adfb494c4d3b53fad4fc44ce2da4db629c50cf627901b804.476f6c64 + 1000000 01f0ef87e344b733286dfce55cfd7e10c90b57a3b1825c984454ce6a.49726f6e + 999998544685 lovelace. 

New balance after adding extra lovelaces 1 569c5e8498ee05e8651ad68b6c81f9756852e218933db722ebc72b90.436f6c6f6e794f776e6572 + 999900 02384095adfb494c4d3b53fad4fc44ce2da4db629c50cf627901b804.476f6c64 + 1000000 01f0ef87e344b733286dfce55cfd7e10c90b57a3b1825c984454ce6a.49726f6e + 1000001667970 lovelace. 

Expected balance difference of 1 569c5e8498ee05e8651ad68b6c81f9756852e218933db722ebc72b90.436f6c6f6e794f776e6572 + -100 02384095adfb494c4d3b53fad4fc44ce2da4db629c50cf627901b804.476f6c64, but the actual difference was 1 569c5e8498ee05e8651ad68b6c81f9756852e218933db722ebc72b90.436f6c6f6e794f776e6572 + -100 02384095adfb494c4d3b53fad4fc44ce2da4db629c50cf627901b804.476f6c64 + 1667970 lovelace

Expected behavior Successful check of wallet balance.

Station (please complete the following information):

sourabhxyz commented 5 months ago

So your wallet was suppose to lose 100 of 02384095adfb494c4d3b53fad4fc44ce2da4db629c50cf627901b804.476f6c64 and gain one of 569c5e8498ee05e8651ad68b6c81f9756852e218933db722ebc72b90.436f6c6f6e794f776e6572, are you sure that in the operation you are doing, wallet is not suppose to receive any ada?

Fiftyw3bs commented 5 months ago

Below is an excerpt of the off-chain code:

return $ fromJust (mustMint (GYMintScript $ colonyMintingPolicy' cSettings stepAddress treasuryAddress colony) redeemer
                              <$> tokenNameFromPlutus (fromMemberTypeToTokenName ColonyOwner)
                              <*> Just (toInteger (length creators)))
            <>
            foldMap mustBeSignedBy creators
            <>
            foldMap mustHaveOutput (GYTxOut <$> (addressFromPubKeyHash GYTestnetPreprod <$> creators)
                                           <*> [fromRight (valueFromLovelace 0) $ valueFromPlutus colonyOwnerToken]
                                           <*> [Just (colonyDatum, GYTxOutUseInlineDatum)]
                                           <*> [Nothing])
            <>
            mustHaveOutput (mkGYTxOut feeAddress (colonyCreationFee' cSettings) colonyDatum)

colonyCreationFee' is the 100 fakeGold (02384095adfb494c4d3b53fad4fc44ce2da4db629c50cf627901b804.476f6c64) colonyOwnerToken is 569c5e8498ee05e8651ad68b6c81f9756852e218933db722ebc72b90.436f6c6f6e794f776e6572

Could it be that change is being returned to the creator's wallet?

BTW, how do I activate traces? I've stopped seeing them since I bumped atlas to v0.4.0