Skip to content

Commit

Permalink
add tests for decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
janmazak committed Jun 21, 2022
1 parent b5bed81 commit ecdb9e4
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 1 deletion.
55 changes: 55 additions & 0 deletions test/integration/__fixtures__/signTx.ts
Expand Up @@ -861,6 +861,33 @@ export const testsMary: SignTxTestcase[] = [
auxiliaryDataSupplement: null,
},
},
{
testname: "Sign tx with output with decimal places",
tx: {
network: Networks.Mainnet,
inputs: [inputs.utxoShelley],
outputs: [outputs.multiassetDecimalPlaces],
fee: 33,
},
signingMode: TransactionSigningMode.ORDINARY_TRANSACTION,
txBody: "a400818258203b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b700018002182a09a2581c6954264b15bc92d6d592febeac84f14645e1ed46ca5ebb9acdb5c15fa14553545249503a0034bf14581caf2e27f580f7f08e93190a81f72462f153026d06450924726645891ba244445249501904d24cffffffffffffffffffffffff1904d2",
expectedResult: {
txHashHex: "a36c270c8ee52c8f5b9cc47ccad0869ad72f00dd1ac1510b682752e09738a27f",
"witnesses": [
{
"path": [
2147485500,
2147485463,
2147483648,
0,
0,
],
"witnessSignatureHex": "30e8da0b9230bc1b1e2748ef51e9259f457d4e0bd0387eb186ade839f3bbac5a2face7eea72061b850c7d26a5b66bd0f90cff546c6c30e0987091a067c960d06",
},
],
auxiliaryDataSupplement: null,
},
},
{
testname: "Sign tx with mint fields with various amounts",
tx: {
Expand Down Expand Up @@ -888,6 +915,34 @@ export const testsMary: SignTxTestcase[] = [
auxiliaryDataSupplement: null,
},
},
{
testname: "Sign tx with mint with decimal places",
tx: {
network: Networks.Mainnet,
inputs: [inputs.utxoShelley],
outputs: [outputs.externalShelleyBaseKeyhashKeyhash],
fee: 33,
mint: mints.mintWithDecimalPlaces,
},
signingMode: TransactionSigningMode.ORDINARY_TRANSACTION,
txBody: "a400818258203b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b700018002182a09a2581c6954264b15bc92d6d592febeac84f14645e1ed46ca5ebb9acdb5c15fa14553545249503a0034bf14581caf2e27f580f7f08e93190a81f72462f153026d06450924726645891ba244445249501904d24cffffffffffffffffffffffff1904d2",
expectedResult: {
txHashHex: "f15863b8ade43da43d14cc2d519982fa3402d4024de272b2d16111cfa99985bc",
"witnesses": [
{
"path": [
2147485500,
2147485463,
2147483648,
0,
0,
],
"witnessSignatureHex": "906fc532008b75ad6f77db60ef4c661983a6310527a0f44203f7e476480395a8d415ccd764051d31bcfae1db50288d7559caf2977c4126113e9be5f9b7c63a02",
},
],
auxiliaryDataSupplement: null,
},
},
{
testname: "Sign tx with mint fields among other fields",
tx: {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/__fixtures__/signTxPlutus.ts
Expand Up @@ -30,7 +30,7 @@ export const testsAlonzo: SignTxTestcase[] = [
},
},
{
// TODO somewhat odd since it does not contain any Plutus elements, differs only in UI
// tx does not contain any Plutus elements, but should be accepted (differs only in UI)
testname: "Sign tx with change output (Plutus)",
tx: {
...mainnetFeeTtl,
Expand Down
60 changes: 60 additions & 0 deletions test/integration/__fixtures__/txElements.ts
Expand Up @@ -210,11 +210,39 @@ export const destinations: Record<
}

export const mints: Record<
| 'mintWithDecimalPlaces'
| 'mintAmountVariety'
| 'mintInvalidCanonicalOrderingPolicy'
| 'mintInvalidCanonicalOrderingAssetName'
, Array<AssetGroup>
> = {
mintWithDecimalPlaces: [
{
policyIdHex: "6954264b15bc92d6d592febeac84f14645e1ed46ca5ebb9acdb5c15f",
tokens: [
{
// fingerprint: asset155nxgqj5acff7fdhc8ranfwyl7nq4ljrks7l6w
assetNameHex: "5354524950",
amount: "-3456789", // -3,456.789
},
],
},
{
policyIdHex: "af2e27f580f7f08e93190a81f72462f153026d06450924726645891b",
tokens: [
{
// fingerprint: asset14yqf3pclzx88jjahydyfad8pxw5xhuca6j7k2p
assetNameHex: "44524950",
amount: "1234", // 0.01234
},
{
// fingerprint: asset12wejgxu04lpg6h3pm056qd207k2sfh7yjklclf
assetNameHex: "ffffffffffffffffffffffff",
amount: "1234", // 1,234 with warning
},
],
},
],
mintAmountVariety: [
{
// fingerprints taken from CIP 14 draft
Expand Down Expand Up @@ -305,6 +333,7 @@ export const outputs: Record<
| 'internalPointer'
| 'multiassetOneToken'
| 'multiassetManyTokens'
| 'multiassetDecimalPlaces'
| 'multiassetChange'
| 'multiassetBigNumber'
| 'multiassetInvalidAssetGroupOrdering'
Expand Down Expand Up @@ -417,6 +446,37 @@ export const outputs: Record<
},
],
},
multiassetDecimalPlaces: {
destination: destinations.multiassetThirdParty,
amount: "1234",
tokenBundle: [
{
policyIdHex: "6954264b15bc92d6d592febeac84f14645e1ed46ca5ebb9acdb5c15f",
tokens: [
{
// fingerprint: asset155nxgqj5acff7fdhc8ranfwyl7nq4ljrks7l6w
assetNameHex: "5354524950",
amount: "3456789", // 3,456.789
},
],
},
{
policyIdHex: "af2e27f580f7f08e93190a81f72462f153026d06450924726645891b",
tokens: [
{
// fingerprint: asset14yqf3pclzx88jjahydyfad8pxw5xhuca6j7k2p
assetNameHex: "44524950",
amount: "1234", // 0.01234
},
{
// fingerprint: asset12wejgxu04lpg6h3pm056qd207k2sfh7yjklclf
assetNameHex: "ffffffffffffffffffffffff",
amount: "1234", // 1,234 with warning
},
],
},
],
},
multiassetChange: {
destination: destinations.internalBaseWithStakingPath,
amount: "1234",
Expand Down

0 comments on commit ecdb9e4

Please sign in to comment.