From 90ee22ef15e29c94a46ceddd356766a8f19b3a48 Mon Sep 17 00:00:00 2001 From: Artur Sapek Date: Wed, 27 Nov 2024 11:57:51 -0500 Subject: [PATCH] add unit tests to document and test this behavior --- platforms/evm/__tests__/unit/platform.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/platforms/evm/__tests__/unit/platform.test.ts b/platforms/evm/__tests__/unit/platform.test.ts index 196a82321..a4947ad9e 100644 --- a/platforms/evm/__tests__/unit/platform.test.ts +++ b/platforms/evm/__tests__/unit/platform.test.ts @@ -20,6 +20,10 @@ import { chains, } from '@wormhole-foundation/sdk-connect'; +import { + toNative, +} from '@wormhole-foundation/sdk-definitions'; + import '@wormhole-foundation/sdk-evm-core'; import '@wormhole-foundation/sdk-evm-tokenbridge'; import { EvmPlatform } from '../../src/platform.js'; @@ -38,6 +42,26 @@ const configs = CONFIG[network].chains; // const satisfiesInterface: PlatformUtils = EvmPlatform; describe('EVM Platform Tests', () => { + describe("Parse Ethereum address", function () { + test("should correctly parse Ethereum addresses", () => { + expect(() => + toNative('Ethereum', '0xaaee1a9723aadb7afa2810263653a34ba2c21c7a') + ).toBeTruthy(); + }); + + test("should correctly handle zero-padded Ethereum addresses (in universal address format)", () => { + expect(() => + toNative('Ethereum', '0x000000000000000000000000aaee1a9723aadb7afa2810263653a34ba2c21c7a') + ).toBeTruthy(); + }); + + test("should throw when parsing an invalid Ethereum addresses", () => { + expect(() => + toNative('Ethereum', '0xabd62c91e3bd89243c592b93b9f45cf9f584be3df4574e05ae31d02fcfef67fc') + ).toThrow(); + }); + }); + describe('Get Token Bridge', () => { test('No RPC', async () => { const p = new EvmPlatform(network, {});