Closed KtorZ closed 5 years ago
The Sqlite DB backend sorts transaction history by slot only. This test case has a TxHistory with two transactions, and readTxHistory
returned them in a different order to the model.
I will address this failure by adding a secondary ordering by txid (ascending) in Sqlite, then ensure the model does the same.
Debugging this is quite hard due to the amount of noise in the test case. It would be good if we could:
show tx
as the function to calculate a TxId.lgtm :+1:
Context
In an unrelated PR, I ran into the following unit test failure:Cardano.Wallet.DB.Sqlite.StateMachine - Sequential
```hs 1) Cardano.Wallet.DB.Sqlite, Sqlite State machine tests, Sequential Falsifiable (after 186 tests and 39 shrinks): Commands { unCommands = [ Command (At (CreateWallet (MWid "b") (Wallet UTxO { getUTxO = fromList [] } (fromList []) BlockHeader { slotId = SlotId { epochNumber = 0 , slotNumber = 0 } , prevBlockHash = Hash { getHash = "genesis" } } SeqState { internalPool = AddressPool { accountPubKey = Key { getKey = XPub { xpubPublicKey = "Q\170\GS\202\198\&2KA\203\CANN'X\154 \139\DEL\FS\148\FSb\SO\RS\r\DLEAL\151\153\137\167\194" , xpubChaincode = ChainCode "\204\196\"I\225y\132\196L\243\128\180\137\246,W\248@\137\225P$[\244\156Cm\v\151\t\197\143" } } , gap = AddressPoolGap { getAddressPoolGap = 14 } , indexedAddresses = fromList [ ( Address { unAddress = "\v\149\SI\172\228\ESC\251C\254<\a\b:;\219\198\210\164\228I(\163\188\183\223\178\&3\241{~\165\154j\US\197\247\193\179\129\202\148\176\STX\FS:\199\200\&1v\236\164zLD\202\DC4\173)i\248\230\160_\183" } , Index { getIndex = 2 } ) , ( Address { unAddress = "\SO\170\129a_6\213' A\194\249\&7\144\162\155\188\141a\191\157:\128\&1_\221\254\184\a\185\233\SIB\161\FS57\179\192\132`\222v\183\164n#\220\\\188=xb\230\135\219f\153\a:\176Wf\160" } , Index { getIndex = 12 } ) , ( Address { unAddress = "\RS\239\147WId\DC1\152\&5d\129\211XZy=A1\245\228-2\153\128[\205\DC3#dL\ETX,\194\213\DC1\DC4\211\&2\232\193\203:\193\178Z\240@|v3\232\200\201\DC3KI.\194\175\238k\206\SI\128" } , Index { getIndex = 19 } ) , ( Address { unAddress = "@\255\173.\229\241\188\229\237\ng4\\I\242|\160\US\162\135\223w\140\138\201\NAKS\ETBR\149\197\186\145\252\220I\223f\195\194\150\&8\228\235~hF\129\232\185%\153\176\173.\194\185vb\DC4\195\244;q" } , Index { getIndex = 5 } ) , ( Address { unAddress = "F\216\165\232\&9\138\202\NAK\200\130\208l#\139\238\236\240\&7Q%\255\238I\NUL\238\181\"\EM\196\137\190\EM\215\128\243\129bN\220\234\DC1\CAN,%\131\255\EOT,\252\223\242x\162\158\&8\146\195U\228\192\228\189\230I" } , Index { getIndex = 3 } ) , ( Address { unAddress = "`|\194\195\223\DC4\DC4a.\vJ\188\148\183\173Kd$\198\242\DEL\138=\143\141QQw\133gr%3o\142\143\249D!\135\228\158\GS\133\187 \135\&0\186S\239s\250\DEL\136Y\221\171\204^\223\207\187`" } , Index { getIndex = 6 } ) , ( Address { unAddress = "e\DC1w\164\SO\183S\194I}\154?\253\170aD\EOTE!\224\174\187Ip\197Um\130O\233\228\234l=5l\199T\202r\178\235I\215R\DC3Z\175\195,\167\244\143\&2\250\157\147.\130Ms[\SYN\145" } , Index { getIndex = 11 } ) , ( Address { unAddress = "\131\133\a\172;NK\DLE\191\194\168\252\239\DLE\221\\\216\RSM=\167\223\247\ETXX\214\239@\180\167\223\146cG\\\EM\153\240\176gI\148\223d\131\205\251\186\231\227k\156\156\141\193{\244!\158\183\224\152\138K" } , Index { getIndex = 0 } ) , ( Address { unAddress = "\138\216\CAN\CAN\149\245U\222\133\151\246Z\b\156i\206\&6\165\STX\EM\202\162\DC2:Q\f\140d\CAN\DC2\SOH\136bg\189+!w\134V8\186\211u\231C|\193\139\GS\164\225\&7\205j/\171K\179\210b\176\198\t" } , Index { getIndex = 22 } ) , ( Address { unAddress = "\147\189H\205\142\DEL\180\\:$\202\STXvF\157 *\GS\130[\134,\179\226C3!\EOT\228\r\n\a\SUB\226\245\199\210`v?\193\&65\141\242\DLE\DC2\193\239\223z\SO\174\150=\140L(\241\147\191\149\130t" } , Index { getIndex = 9 } ) , ( Address { unAddress = "\149\EM7f\200\148{\218\179\&0QT\128.\NULe\220\DLE \170J\225\201\213\188\203w5\SYN\232l%G\182\246\174\151\200\&2\250\ETB#\f\184\176\143\192\160x\251\131c\223\230#\250\218M\206\129\195\193\206\&2" } , Index { getIndex = 18 } ) , ( Address { unAddress = "\149\152;\214\183\181\ESC*\158\DC2\a\180\204\162\175\147\157{\188\135\193\134\200\240\146H\196\247\209\"z\145\208[\ETB\158\&1q\243\148\139k]\230K8\203\192r\v\141\164E\201\DC3|Z\ETX\143A\247\199\DC2\205" } , Index { getIndex = 13 } ) , ( Address { unAddress = "\150\ETB\173\ETX\148\143\162k \133V\DC2\248\155\128\213A\225E\203\210jx\159\195cN\169\195P\DEL\242\192hg\232Oo\166\170\170\163J\229\174.\171u;\131}\231\147\157\149&G\222\213\148\136j3\ESC" } , Index { getIndex = 17 } ) , ( Address { unAddress = "\170\222\247\173\178\217_\208\a\222p\141\210\200\&4oG\180\210\214\239\&6\"|\183\SOH!\147\132/\146\235{\156h\t\DC2\238\193\185\248\181\145Qv_9\v\148\\\SI\\e\140)\225J\186z\225\146)\240U" } , Index { getIndex = 1 } ) , ( Address { unAddress = "\185\NAK\253\150\134\248\137\\[,\NUL\248\180\136\244\173+=8s\237Mal\136\152Q\154\163\202a\147\188\218b\205\EMG\142\DLEs\150g\182\228$&w\t\221\172\RS!\197Y/f\237\173\\\244S;\243" } , Index { getIndex = 21 } ) , ( Address { unAddress = "\190T\DC2L1O5\NAK%\ACK\226\SO\152\149\221\172$\vNp\208FSk\185\168\FS\172)9\221!Q\185p\SI+\158Uzp\175R\252bp\220k\253y\ETB+4\195kl\146J\213>\211E\222I" } , Index { getIndex = 10 } ) , ( Address { unAddress = "\194+~\186\152\DC1\215\181\158\249\253\164u\175\EM\212\&7\US\SOH\174\247\139.*!\233\175\149\247\214\131\178U\SIb\165P\ESC\193\249m\147\140\&8\187C\231\129\195\NAK\211\245\RS\206`K\144\206\191\161!\183\158D" } , Index { getIndex = 8 } ) , ( Address { unAddress = "\197\150\USFp\150\247\202\NUL\193o\221\&5N\165|Q\213\DLE\254\146\RS0\EM\137\b\240\CAN\USw\134\130\248!\142\219\143\155+\EM\210\146 /y\157K\219KO\241r\US\177\188\DC2T,Wy\a\141-\143" } , Index { getIndex = 16 } ) , ( Address { unAddress = "\215T\EOTvw\241\129\184\\\179\182\201\218\254\r\253\228\176\164\220o\ETX\FSbb\160\&4\255\153\244E:Q\249\211\161\194R_\DC2+\161\a\v\180\182k]p&J\223\DC4\ENQ\STX\183ql\SI5t\248P\129" } , Index { getIndex = 20 } ) , ( Address { unAddress = "\240=\252#(\186I^j\DC2\160\191\189\210\176\153\230s\130\131\147u\160\&4\134-\218\150V(\152\144\235#\254x-e*\133]\140\CANKT\161\247\162\251\251\&5\173\197\158\218\t\171wY\230\248\&9\154<" } , Index { getIndex = 14 } ) , ( Address { unAddress = "\244M\229\255k\249a\231\132\f\128\161\210\&9\209\191\&6a\SUB)n\141C\r\"\158\184B*\200\186\184\148S\226x\178C\173\157\224y>Y\177\179\229\238\252\135\180?\ENQ\216\239\136\232\250>\146\192+%m" } , Index { getIndex = 4 } ) , ( Address { unAddress = "\252Nb\136\FS\CAN\v\222\FS\b\230M\247\225bT\235Y\201b\196\145\199\231\243\207\156|\209R\245\SYNO\162\140\tQ\213)\GS\182\&6\247\221Q\viF\149G\168Cv\144\154\224J\173nB 5\134\210" } , Index { getIndex = 7 } ) , ( Address { unAddress = "\253\ACK\255\168J&\FS\ETXPe\211#\196.\230\bf\134\191\178\182\ETB2\136\DC3O\235tc)\156\SO\133\240\248\244\194\240\&8\137\SO\230\169\132\150\241\241\227\247C\205\159\158\220.\224\243\174.\232wP\184\&2" } , Index { getIndex = 15 } ) ] } , externalPool = AddressPool { accountPubKey = Key { getKey = XPub { xpubPublicKey = "Q\170\GS\202\198\&2KA\203\CANN'X\154 \139\DEL\FS\148\FSb\SO\RS\r\DLEAL\151\153\137\167\194" , xpubChaincode = ChainCode "\204\196\"I\225y\132\196L\243\128\180\137\246,W\248@\137\225P$[\244\156Cm\v\151\t\197\143" } } , gap = AddressPoolGap { getAddressPoolGap = 11 } , indexedAddresses = fromList [ ( Address { unAddress = "\r\225\208\DEL\196 \"m\144\140\250\187\147\158\163\189\ETB\216\fK(\185\ETX\168\144\206D\197\DC2\206I\RS28\232WR \190\146=)`~a0\227N\147 \183\136UBExpected behavior
Tests shouldn't fail :upside_down_face:
Actual behavior
It fails.
Resolution Plan
PR
master
QA
See comment below: https://github.com/input-output-hk/cardano-wallet/issues/551#issuecomment-514513283
576 makes sure to make the sorting stable by pre-sorting over the tx id.