diff --git a/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs b/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs index 53ee7788129..f39c5965b65 100644 --- a/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs +++ b/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs @@ -1414,12 +1414,30 @@ binaryCalculationsSpec (AnyCardanoEra era) = ShelleyBasedEraMary -> binaryCalculationsSpec' @Cardano.MaryEra shelleyEra ShelleyBasedEraAlonzo -> - pure () -- TO_DO when ledger's PR 2863 is included in node bump - --binaryCalculationsSpec' @Cardano.AlonzoEra shelleyEra + binaryCalculationsSpec' @Cardano.AlonzoEra shelleyEra ShelleyBasedEraBabbage -> - pure () -- TO_DO when ledger's PR 2863 is included in node bump - --binaryCalculationsSpec' @Cardano.BabbageEra shelleyEra - + binaryCalculationsSpec' @Cardano.BabbageEra shelleyEra + +-- Up till Mary era we have the following structure of transaction +-- transaction = +-- [ transaction_body +-- , transaction_witness_set +-- , auxiliary_data / null +-- ] +-- So we begin with 3-element array binary prefix, that is encoded as '83' +-- From Alonzo on tx was enriched for isValid field making it +-- 4-element array that is encoded as '84'. +-- transaction = +-- [ transaction_body +-- , transaction_witness_set +-- , bool +-- , auxiliary_data / null +-- ] +-- Alonzo transaction stil has the same binary representation (array) +-- for transaction outputs like in the previous eras. +-- Babbage era changes this representation, and introduces map binary +-- representation for transaction outputs as the concept of them is +-- extended in this era. binaryCalculationsSpec' :: forall era. EraConstraints era => ShelleyBasedEra era -> Spec @@ -1443,18 +1461,49 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do let chgs = [ TxOut (dummyAddress 2) (coinToBundle amtChange) ] - calculateBinary net utxo outs chgs pairs `shouldBe` - "83a40081825820000000000000000000000000000000000000000000000000\ - \00000000000000000001828258390101010101010101010101010101010101\ - \01010101010101010101010101010101010101010101010101010101010101\ - \0101010101010101011a001e84808258390102020202020202020202020202\ - \02020202020202020202020202020202020202020202020202020202020202\ - \0202020202020202020202021a0078175c021a0001faa403191e46a1028184\ - \58200100000000000000000000000000000000000000000000000000000000\ - \0000005840d7af60ae33d2af351411c1445c79590526990bfa73cbb3732b54\ - \ef322daa142e6884023410f8be3c16e9bd52076f2bb36bf38dfe034a9f0465\ - \8e9f56197ab80f582000000000000000000000000000000000000000000000\ - \0000000000000000000041a0f6" + let binary = case era of + ShelleyBasedEraBabbage -> + "84a400818258200000000000000000000000000000000000000000\ + \000000000000000000000000000182a20058390101010101010101\ + \010101010101010101010101010101010101010101010101010101\ + \01010101010101010101010101010101010101010101011a001e84\ + \80a200583901020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \0202020202020202011a0078175c021a0001faa403191e46a10281\ + \845820010000000000000000000000000000000000000000000000\ + \000000000000000058407154db81463825f150bb3b9b0824caf151\ + \3716f73498afe61d917a5621912a2b3df252bea14683a9ee56710d\ + \483a53a5aa35247e0d2b80e6300f7bdec763a20458200000000000\ + \000000000000000000000000000000000000000000000000000000\ + \41a0f5f6" + ShelleyBasedEraAlonzo -> + "84a400818258200000000000000000000000000000000000000000\ + \000000000000000000000000000182825839010101010101010101\ + \010101010101010101010101010101010101010101010101010101\ + \0101010101010101010101010101010101010101011a001e848082\ + \583901020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \02020202021a0078175c021a0001faa403191e46a1028184582001\ + \000000000000000000000000000000000000000000000000000000\ + \000000005840d7af60ae33d2af351411c1445c79590526990bfa73\ + \cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb3\ + \6bf38dfe034a9f04658e9f56197ab80f5820000000000000000000\ + \000000000000000000000000000000000000000000000041a0f5f6" + _ -> + "83a400818258200000000000000000000000000000000000000000\ + \000000000000000000000000000182825839010101010101010101\ + \010101010101010101010101010101010101010101010101010101\ + \0101010101010101010101010101010101010101011a001e848082\ + \583901020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \02020202021a0078175c021a0001faa403191e46a1028184582001\ + \000000000000000000000000000000000000000000000000000000\ + \000000005840d7af60ae33d2af351411c1445c79590526990bfa73\ + \cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb3\ + \6bf38dfe034a9f04658e9f56197ab80f5820000000000000000000\ + \000000000000000000000000000000000000000000000041a0f6" + + calculateBinary net utxo outs chgs pairs `shouldBe` binary it "2 inputs, 3 outputs" $ do let pairs = [dummyWit 0, dummyWit 1] @@ -1477,26 +1526,76 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do let chgs = [ TxOut (dummyAddress 4) (coinToBundle amtChange) ] - calculateBinary net utxo outs chgs pairs `shouldBe` - "83a40082825820000000000000000000000000000000000000000000000000\ - \00000000000000000082582000000000000000000000000000000000000000\ - \00000000000000000000000000010183825839010202020202020202020202\ - \02020202020202020202020202020202020202020202020202020202020202\ - \02020202020202020202020202021a005b8d80825839010303030303030303\ - \03030303030303030303030303030303030303030303030303030303030303\ - \03030303030303030303030303030303031a005b8d80825839010404040404\ - \04040404040404040404040404040404040404040404040404040404040404\ - \04040404040404040404040404040404040404041a007801e0021a00021020\ - \03191e46a10282845820010000000000000000000000000000000000000000\ - \00000000000000000000005840e8e769ecd0f3c538f0a5a574a1c881775f08\ - \6d6f4c845b81be9b78955728bffa7efa54297c6a5d73337bd6280205b1759c\ - \13f79d4c93f29871fc51b78aeba80e58200000000000000000000000000000\ - \00000000000000000000000000000000000041a0845820130ae82201d7072e\ - \6fbfc0a1884fb54636554d14945b799125cf7ce38d477f5158405835ff78c6\ - \fc5e4466a179ca659fa85c99b8a3fba083f3f3f42ba360d479c64ef169914b\ - \52ade49b19a7208fd63a6e67a19c406b4826608fdc5307025506c307582001\ - \01010101010101010101010101010101010101010101010101010101010101\ - \41a0f6" + let binary = case era of + ShelleyBasedEraBabbage -> + "84a400828258200000000000000000000000000000000000000000\ + \000000000000000000000000008258200000000000000000000000\ + \000000000000000000000000000000000000000000010183a20058\ + \390102020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \02020202011a005b8d80a200583901030303030303030303030303\ + \030303030303030303030303030303030303030303030303030303\ + \0303030303030303030303030303030303011a005b8d80a2005839\ + \010404040404040404040404040404040404040404040404040404\ + \040404040404040404040404040404040404040404040404040404\ + \040404011a007801e0021a0002102003191e46a102828458200100\ + \000000000000000000000000000000000000000000000000000000\ + \00000058401a8667d2d0af4e24d4d385443002f1e9036063bdb7c6\ + \2d45447a2e176ded81a11683bd944c6d7db6e5fd886840025f6319\ + \2a382e526f4150e2b336ee9ed80808582000000000000000000000\ + \0000000000000000000000000000000000000000000041a0845820\ + \130ae82201d7072e6fbfc0a1884fb54636554d14945b799125cf7c\ + \e38d477f515840320ed7d1513b0f1b61381f7942a07b627b246c85\ + \a13b2623e4868ea82488c778a7760124f3a17f924c08d425c0717d\ + \f6cd898eb4ab8439a16e08befdc415120e58200101010101010101\ + \01010101010101010101010101010101010101010101010141a0f5\ + \f6" + ShelleyBasedEraAlonzo -> + "84a400828258200000000000000000000000000000000000000000\ + \000000000000000000000000008258200000000000000000000000\ + \000000000000000000000000000000000000000000010183825839\ + \010202020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \0202021a005b8d8082583901030303030303030303030303030303\ + \030303030303030303030303030303030303030303030303030303\ + \03030303030303030303030303031a005b8d808258390104040404\ + \040404040404040404040404040404040404040404040404040404\ + \040404040404040404040404040404040404040404040404041a00\ + \7801e0021a0002102003191e46a102828458200100000000000000\ + \0000000000000000000000000000000000000000000000005840e8\ + \e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b81be9b7895\ + \5728bffa7efa54297c6a5d73337bd6280205b1759c13f79d4c93f2\ + \9871fc51b78aeba80e582000000000000000000000000000000000\ + \0000000000000000000000000000000041a0845820130ae82201d7\ + \072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f5158\ + \405835ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42b\ + \a360d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b48\ + \26608fdc5307025506c30758200101010101010101010101010101\ + \01010101010101010101010101010101010141a0f5f6" + _ -> + "83a400828258200000000000000000000000000000000000000000\ + \000000000000000000000000008258200000000000000000000000\ + \000000000000000000000000000000000000000000010183825839\ + \010202020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \0202021a005b8d8082583901030303030303030303030303030303\ + \030303030303030303030303030303030303030303030303030303\ + \03030303030303030303030303031a005b8d808258390104040404\ + \040404040404040404040404040404040404040404040404040404\ + \040404040404040404040404040404040404040404040404041a00\ + \7801e0021a0002102003191e46a102828458200100000000000000\ + \0000000000000000000000000000000000000000000000005840e8\ + \e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b81be9b7895\ + \5728bffa7efa54297c6a5d73337bd6280205b1759c13f79d4c93f2\ + \9871fc51b78aeba80e582000000000000000000000000000000000\ + \0000000000000000000000000000000041a0845820130ae82201d7\ + \072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f5158\ + \405835ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42b\ + \a360d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b48\ + \26608fdc5307025506c30758200101010101010101010101010101\ + \01010101010101010101010101010101010141a0f6" + + calculateBinary net utxo outs chgs pairs `shouldBe` binary describe "Byron witnesses - testnet" $ do let net = Cardano.Testnet (Cardano.NetworkMagic 0) @@ -1517,18 +1616,51 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do let chgs = [ TxOut (dummyAddress 2) (coinToBundle amtChange) ] - calculateBinary net utxo outs chgs pairs `shouldBe` - "83a40081825820000000000000000000000000000000000000000000000000\ - \00000000000000000001828258390101010101010101010101010101010101\ - \01010101010101010101010101010101010101010101010101010101010101\ - \0101010101010101011a001e84808258390102020202020202020202020202\ - \02020202020202020202020202020202020202020202020202020202020202\ - \0202020202020202020202021a0078175c021a0001faa403191e46a1028184\ - \58200100000000000000000000000000000000000000000000000000000000\ - \0000005840d7af60ae33d2af351411c1445c79590526990bfa73cbb3732b54\ - \ef322daa142e6884023410f8be3c16e9bd52076f2bb36bf38dfe034a9f0465\ - \8e9f56197ab80f582000000000000000000000000000000000000000000000\ - \0000000000000000000044a1024100f6" + let binary = case era of + ShelleyBasedEraBabbage -> + "84a400818258200000000000000000000000000000000000000000\ + \000000000000000000000000000182a20058390101010101010101\ + \010101010101010101010101010101010101010101010101010101\ + \01010101010101010101010101010101010101010101011a001e84\ + \80a200583901020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \0202020202020202011a0078175c021a0001faa403191e46a10281\ + \845820010000000000000000000000000000000000000000000000\ + \000000000000000058407154db81463825f150bb3b9b0824caf151\ + \3716f73498afe61d917a5621912a2b3df252bea14683a9ee56710d\ + \483a53a5aa35247e0d2b80e6300f7bdec763a20458200000000000\ + \000000000000000000000000000000000000000000000000000000\ + \44a1024100f5f6" + ShelleyBasedEraAlonzo -> + "84a400818258200000000000000000000000000000000000000000\ + \000000000000000000000000000182825839010101010101010101\ + \010101010101010101010101010101010101010101010101010101\ + \0101010101010101010101010101010101010101011a001e848082\ + \583901020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \02020202021a0078175c021a0001faa403191e46a1028184582001\ + \000000000000000000000000000000000000000000000000000000\ + \000000005840d7af60ae33d2af351411c1445c79590526990bfa73\ + \cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb3\ + \6bf38dfe034a9f04658e9f56197ab80f5820000000000000000000\ + \000000000000000000000000000000000000000000000044a10241\ + \00f5f6" + _ -> + "83a400818258200000000000000000000000000000000000000000\ + \000000000000000000000000000182825839010101010101010101\ + \010101010101010101010101010101010101010101010101010101\ + \0101010101010101010101010101010101010101011a001e848082\ + \583901020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \02020202021a0078175c021a0001faa403191e46a1028184582001\ + \000000000000000000000000000000000000000000000000000000\ + \000000005840d7af60ae33d2af351411c1445c79590526990bfa73\ + \cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb3\ + \6bf38dfe034a9f04658e9f56197ab80f5820000000000000000000\ + \000000000000000000000000000000000000000000000044a10241\ + \00f6" + + calculateBinary net utxo outs chgs pairs `shouldBe` binary it "2 inputs, 3 outputs" $ do let pairs = [dummyWit 0, dummyWit 1] @@ -1551,26 +1683,77 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do let chgs = [ TxOut (dummyAddress 4) (coinToBundle amtChange) ] - calculateBinary net utxo outs chgs pairs `shouldBe` - "83a40082825820000000000000000000000000000000000000000000000000\ - \00000000000000000082582000000000000000000000000000000000000000\ - \00000000000000000000000000010183825839010202020202020202020202\ - \02020202020202020202020202020202020202020202020202020202020202\ - \02020202020202020202020202021a005b8d80825839010303030303030303\ - \03030303030303030303030303030303030303030303030303030303030303\ - \03030303030303030303030303030303031a005b8d80825839010404040404\ - \04040404040404040404040404040404040404040404040404040404040404\ - \04040404040404040404040404040404040404041a007801e0021a00021020\ - \03191e46a10282845820130ae82201d7072e6fbfc0a1884fb54636554d1494\ - \5b799125cf7ce38d477f5158405835ff78c6fc5e4466a179ca659fa85c99b8\ - \a3fba083f3f3f42ba360d479c64ef169914b52ade49b19a7208fd63a6e67a1\ - \9c406b4826608fdc5307025506c30758200101010101010101010101010101\ - \01010101010101010101010101010101010144a10241008458200100000000\ - \0000000000000000000000000000000000000000000000000000005840e8e7\ - \69ecd0f3c538f0a5a574a1c881775f086d6f4c845b81be9b78955728bffa7e\ - \fa54297c6a5d73337bd6280205b1759c13f79d4c93f29871fc51b78aeba80e\ - \58200000000000000000000000000000000000000000000000000000000000\ - \00000044a1024100f6" + let binary = case era of + ShelleyBasedEraBabbage -> + "84a400828258200000000000000000000000000000000000000000\ + \000000000000000000000000008258200000000000000000000000\ + \000000000000000000000000000000000000000000010183a20058\ + \390102020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \02020202011a005b8d80a200583901030303030303030303030303\ + \030303030303030303030303030303030303030303030303030303\ + \0303030303030303030303030303030303011a005b8d80a2005839\ + \010404040404040404040404040404040404040404040404040404\ + \040404040404040404040404040404040404040404040404040404\ + \040404011a007801e0021a0002102003191e46a10282845820130a\ + \e82201d7072e6fbfc0a1884fb54636554d14945b799125cf7ce38d\ + \477f515840320ed7d1513b0f1b61381f7942a07b627b246c85a13b\ + \2623e4868ea82488c778a7760124f3a17f924c08d425c0717df6cd\ + \898eb4ab8439a16e08befdc415120e582001010101010101010101\ + \0101010101010101010101010101010101010101010144a1024100\ + \845820010000000000000000000000000000000000000000000000\ + \000000000000000058401a8667d2d0af4e24d4d385443002f1e903\ + \6063bdb7c62d45447a2e176ded81a11683bd944c6d7db6e5fd8868\ + \40025f63192a382e526f4150e2b336ee9ed8080858200000000000\ + \000000000000000000000000000000000000000000000000000000\ + \44a1024100f5f6" + ShelleyBasedEraAlonzo -> + "84a400828258200000000000000000000000000000000000000000\ + \000000000000000000000000008258200000000000000000000000\ + \000000000000000000000000000000000000000000010183825839\ + \010202020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \0202021a005b8d8082583901030303030303030303030303030303\ + \030303030303030303030303030303030303030303030303030303\ + \03030303030303030303030303031a005b8d808258390104040404\ + \040404040404040404040404040404040404040404040404040404\ + \040404040404040404040404040404040404040404040404041a00\ + \7801e0021a0002102003191e46a10282845820130ae82201d7072e\ + \6fbfc0a1884fb54636554d14945b799125cf7ce38d477f51584058\ + \35ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42ba360\ + \d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b482660\ + \8fdc5307025506c307582001010101010101010101010101010101\ + \0101010101010101010101010101010144a1024100845820010000\ + \000000000000000000000000000000000000000000000000000000\ + \00005840e8e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b\ + \81be9b78955728bffa7efa54297c6a5d73337bd6280205b1759c13\ + \f79d4c93f29871fc51b78aeba80e58200000000000000000000000\ + \00000000000000000000000000000000000000000044a1024100f5\ + \f6" + _ -> + "83a400828258200000000000000000000000000000000000000000\ + \000000000000000000000000008258200000000000000000000000\ + \000000000000000000000000000000000000000000010183825839\ + \010202020202020202020202020202020202020202020202020202\ + \020202020202020202020202020202020202020202020202020202\ + \0202021a005b8d8082583901030303030303030303030303030303\ + \030303030303030303030303030303030303030303030303030303\ + \03030303030303030303030303031a005b8d808258390104040404\ + \040404040404040404040404040404040404040404040404040404\ + \040404040404040404040404040404040404040404040404041a00\ + \7801e0021a0002102003191e46a10282845820130ae82201d7072e\ + \6fbfc0a1884fb54636554d14945b799125cf7ce38d477f51584058\ + \35ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42ba360\ + \d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b482660\ + \8fdc5307025506c307582001010101010101010101010101010101\ + \0101010101010101010101010101010144a1024100845820010000\ + \000000000000000000000000000000000000000000000000000000\ + \00005840e8e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b\ + \81be9b78955728bffa7efa54297c6a5d73337bd6280205b1759c13\ + \f79d4c93f29871fc51b78aeba80e58200000000000000000000000\ + \00000000000000000000000000000000000000000044a1024100f6" + + calculateBinary net utxo outs chgs pairs `shouldBe` binary where slotNo = SlotNo 7750