Update. Added validation in the ETH/TRX conversion op, along with many more tests for numerous ops. Finalized the QA.

This commit is contained in:
David C Goldenberg 2025-05-13 17:01:18 -04:00
parent 5605807778
commit 511d5e6d6d
6 changed files with 178 additions and 14 deletions

View file

@ -20,6 +20,30 @@ TestRegister.addTests([
},
],
},
{
name: "ETH To TRX (Invalid ETH)",
input: "0xAb495f468B0bF116860E76be9f26339b2CbC33c3x",
expectedOutput: "Invalid ETH address. ETH addresses should have 20 bytes (40 characters) prefaced by 0x.",
recipeConfig: [
{
"op": "ETH / TRX Conversion",
"args": ["ETH->TRX"]
},
],
},
{
name: "ETH To TRX (Blank Input)",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "ETH / TRX Conversion",
"args": ["ETH->TRX"]
},
],
},
{
name: "TRX to ETH",
@ -32,6 +56,30 @@ TestRegister.addTests([
},
],
},
{
name: "TRX to ETH (Invalid TRX by Length)",
input: "TRatSrEqUKLK4eNWL8NSrvEbpeht5takWde",
expectedOutput: "Invalid TRX Address. Checksum failed.",
recipeConfig: [
{
"op": "ETH / TRX Conversion",
"args": ["TRX->ETH"]
},
],
},
{
name: "TRX to ETH (Invalid TRX by Character Substitution)",
input: "TRatSrEqUKLK4eNLL8NSrvEbpeht5takWd",
expectedOutput: "Invalid TRX Address. Checksum failed.",
recipeConfig: [
{
"op": "ETH / TRX Conversion",
"args": ["TRX->ETH"]
},
],
},
{
name: "TRX to ETH With Checksum",

View file

@ -33,6 +33,18 @@ TestRegister.addTests([
},
],
},
{
name: "Public Key To ETH Style Address Invalid Uncompressed Key",
input: "027d3e5107b46421c3ddf7292fcbe1f5805952279926c325d119f6ddfed1e5e7ea9a9f5dceadc57b897cb286479450b66a6422f8f270bcd2a61ab4eea800911956",
expectedOutput: "We have a valid hex string of reasonable length, (130) but doesn't start with the right value. Correct values are 04 but we have: 02",
recipeConfig: [
{
"op": "Public Key To ETH Style Address",
"args": []
},
],
},
{
name: "Public Key to ETH Style Address: Compressed Key",
@ -45,6 +57,30 @@ TestRegister.addTests([
},
],
},
{
name: "Public Key to ETH Style Address: Blank Input",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Public Key To ETH Style Address",
"args": []
},
],
},
{
name: "Public Key to ETH Style Address: Invalid Compressed Key",
input: "059d491d3f5a2a79b422b76b8115b175b38e42c6103b1a84c88fb6221fe9072bbe",
expectedOutput: "We have a valid hex string, of reasonable length, (66) but doesn't start with the right value. Correct values are 02, or 03 but we have: 05",
recipeConfig: [
{
"op": "Public Key To ETH Style Address",
"args": [],
},
],
},
{
name: "Public Key to ETH Style Address: Compressed Key 2",

View file

@ -10,6 +10,17 @@ import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Public Key To Address: P2PKH (Empty String)",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2PKH (V1 BTC Addresses)"]
},
],
},
{
name: "Public Key To Address: P2PKH (1)",
input: "03ebf60a619da2fbc6239089ca0a93878ea53baa3d22188cacad4033b103237ae9",

View file

@ -10,6 +10,17 @@ import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Public Key To TRX Style Address, Invalid Uncompressed.",
input: "05187ac6bc2723630c936e363b826de17dac62382e3bbfabf306ad5f55cc79538783889fe32946b52092dad24c56893d522413d67e62b28f6c54f14821367a9edc",
expectedOutput: "We have a valid hex string of reasonable length, (130) but doesn't start with the right value. Correct values are 04 but we have: 05",
recipeConfig: [
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key To TRX Style Address",
input: "04187ac6bc2723630c936e363b826de17dac62382e3bbfabf306ad5f55cc79538783889fe32946b52092dad24c56893d522413d67e62b28f6c54f14821367a9edc",
@ -33,6 +44,42 @@ TestRegister.addTests([
},
],
},
{
name: "Public Key To TRX Style Address Invalid Compressed Key (Length)",
input: "02d1b5855d3f99c4449eb7af576bec1b9bc0bf0769446820686d2de5c47c13b1a0ff",
expectedOutput: "Invalid length. We want either 33, 65 (if bytes) or 66, 130 (if hex) but we got: 68",
recipeConfig: [
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key To TRX Style Address (Empty String)",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key To TRX Style Address Invalid Compressed Key",
input: "06d1b5855d3f99c4449eb7af576bec1b9bc0bf0769446820686d2de5c47c13b1a0",
expectedOutput: "We have a valid hex string, of reasonable length, (66) but doesn't start with the right value. Correct values are 02, or 03 but we have: 06",
recipeConfig: [
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key to ETH Style Address: Compressed Key 2",