Skip to content

[E2E] Tests: API server (register, balance, transfer) #182

@sadiq1971

Description

@sadiq1971

Context

First batch of E2E tests covering the api-server: user registration (EIP-191), token balance queries, and EVM-style transfers between Canton parties.

Files to Create

All in tests/e2e/tests/api/, all with //go:build e2e.

main_test.go

//go:build e2e

package api_test

import (
    "os"
    "testing"

    "github.com/chainsafe/canton-middleware/tests/e2e/devstack/presets"
)

func TestMain(m *testing.M) {
    os.Exit(presets.DoMain(m))
}

register_test.go

Test Scenario
TestRegister_NewUser_Success Whitelist address, sign EIP-191 message, POST /register, assert 200 + canton_party_id non-empty
TestRegister_Duplicate_Idempotent Register same address twice, assert both return same canton_party_id
TestRegister_NotWhitelisted_Fails POST /register without whitelisting first, assert 4xx

balance_test.go

Test Scenario
TestGetBalance_UnregisteredUser_ReturnsZero eth_call balanceOf on unregistered address, expect "0"
TestGetBalance_AfterMintDEMO DSL.MintDEMO then DSL.WaitForCantonBalance, verify balance matches
TestGetTokenMetadata eth_call name/symbol/decimals on PROMPT token, verify non-empty responses

transfer_test.go

Test Scenario
TestTransfer_DEMO_BetweenUsers Register two users, mint DEMO to User1, transfer to User2, verify both balances
TestTransfer_InsufficientBalance_Fails Attempt transfer of more than balance, expect error response
TestTransfer_PROMPT_AfterDeposit Deposit PROMPT via bridge, wait for Canton balance, transfer to User2

Makefile update

test-e2e-api:
	go test -v -tags e2e -timeout 10m ./tests/e2e/tests/api/...

Acceptance Criteria

  • make test-e2e-api passes green against a running stack.
  • Each test is independent: uses t.Helper() + require.* (not assert.*) for fast failure.
  • No test hard-codes addresses or ports — all resolved through sys.Manifest or DSL methods.

Dependencies

Size

M (1 day)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions