How to simulate payments when running integration tests?

I’m currently implementing Taler integration into Tryton. This includes a test-suite. Anyhow, testing payments is cumbersome in e.g. CI tests. sandcastle-ng is great, as it provides some merchants already, thus one “only” needs to create a bank account for the customer.

But how can one automate wallet operations like withdrawal and payments?

Any ides?

Do you want to automate the wallet? You can run taler-wallet-cli in daemon mode and send commands to it (via a unix domain socket)!

It’s not very well documented as this point, but the basic commands are:

# Run the wallet as a daemon
taler-wallet-cli advanced serve
# Instead of using one-shot commands, let the wallet talk to the daemon
export TALER_WALLET_CONNECTION=$HOME/.wallet-core.sock
# Run wallet commands
taler-wallet-cli transactions
[...]
taler-wallet-cli api $request "$payload"
[...]
taler-wallet-cli handle-uri "$taler_uri"
[...]
1 Like

Thanks for asking, this made me rethink my needs.

No, actually I don’t want to interact with the wallet.

The aim is to test the integration against the merchant backend. This is: create order, get order state (paid, unpaid, failed), refund order, get refund state.

I imaging some kind of REST-API backdoor to tell the merchant backend: treat this order as if the customer has paid, as if they did not pay, as if they did pick up the refund, etc.

This is more like mocking answers - expect that I don’t want to mock the answers, since I need to test whether my tooling work correctly with the “real” answers. (Though, if it’s the only way, I might mock.)

Any idea?

We currently don’t have any mocking like this on the roadmap. The easiest way would be to just run an exchange / merchant backend (e.g. via sandcastle-ng) and use a real (headless) wallet to test the integration.

Is there anything about this approach that would not work for you?

I understand that a mocked system is much work and this is why it not on the roadmap. Using sandcastle-ng would be an acceptable solution.

The main issue with this approach is: For operating the wallet, the test suite needs to run shell commands, and this has to be done in the container. Thus there are a lot of additional dependencies on the user’s environment: docker or podman, name of the container, maybe more.

My ideas for working around this: Implement a stupid HTTP service running in the container and proxying wallet operations.

Beside this, I need to know the respective commands to execute. (As of now I did not manage to withdraw KUDOS from the sandcastle bank into the cli-wallet.)

Coming back to this older topic:

An alternative to mocking would be a darn stupid, insecure mini-wallet.

If implemented in e.g. Python, it would be easily available in CI and test suite would control it. For this no daemon nor running process would be required just some simple commands:

  • withdraw
  • pay
  • fetch-refund

Any hints how to implement this?

(To make it clear for everybody that this is only to be used in test-suites, the insecure-dummy-wallet could require an argument like --this-is-insecure-and-will-burn-all-the-money :stuck_out_tongue_winking_eye: )