Skip to content

Commit

Permalink
Merge pull request #59 from cspr-rad/update-e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
marijanp authored Apr 4, 2024
2 parents 36789bc + 803e86d commit 9f5cbb4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions kairos-server/src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct PayloadBody {
#[serde(deserialize_with = "hex_to_vec", serialize_with = "vec_to_hex")]
pub public_key: PublicKey,
#[serde(deserialize_with = "hex_to_vec", serialize_with = "vec_to_hex")]
pub payload: Vec<u8>,
Expand Down
37 changes: 29 additions & 8 deletions nixos/tests/end-to-end.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ nixosTest {
};
services.cctl.enable = true;
environment.systemPackages = [ casper-client-rs ];
# allow HTTP for nixos-test environment
services.nginx.virtualHosts.${config.networking.hostName}.forceSSL = lib.mkForce false;
};

client = { config, pkgs, nodes, ... }: {
Expand All @@ -44,15 +46,34 @@ nixosTest {
kairos.succeed("casper-client get-node-status --node-address http://localhost:11101")
deposit_request = { "public_key": "publickey", "amount": 10 }
# Tx Payload
# nonce = 1
# deposit:
# amount = 1000
#
deposit_payload = "3009020101a004020203e8"
deposit_request = { "public_key": "deadbeef", "payload": deposit_payload, "signature": "cafebabe" }
# REST API
client.succeed("curl -X POST http://kairos/api/v1/deposit -H 'Content-Type: application/json' -d '{}'".format(json.dumps(deposit_request)))
transfer_request = { "from": "publickey", "signature": "signature", "to": "publickey", "amount": 10 }
client.succeed("curl -X POST http://kairos/api/v1/transfer -H 'Content-Type: application/json' -d '{}'".format(json.dumps(transfer_request)))
withdraw_request = { "public_key": "publickey", "signature": "signature", "amount": 10 }
client.succeed("curl -X POST http://kairos/api/v1/withdraw -H 'Content-Type: application/json' -d '{}'".format(json.dumps(withdraw_request)))
client.succeed("curl --fail-with-body -X POST http://kairos/api/v1/deposit -H 'Content-Type: application/json' -d '{}'".format(json.dumps(deposit_request)))
# Tx Payload
# nonce = 2
# transfer:
# recipient = DEADBEEF
# amount = 1000
#
transfer_payload = "300f020102a10a0404deadbeef020203e8"
transfer_request = { "public_key": "deadbeef", "payload": transfer_payload, "signature": "cafebabe" }
client.succeed("curl --fail-with-body -X POST http://kairos/api/v1/transfer -H 'Content-Type: application/json' -d '{}'".format(json.dumps(transfer_request)))
# Tx Payload
# nonce = 3
# withdrawal:
# amount = 1000
#
withdraw_payload = "3009020103a204020203e8"
withdraw_request = { "public_key": "deadbeef", "payload": withdraw_payload, "signature": "cafebabe" }
client.succeed("curl --fail-with-body -X POST http://kairos/api/v1/withdraw -H 'Content-Type: application/json' -d '{}'".format(json.dumps(withdraw_request)))
# CLI with ed25519
cli_output = client.succeed("kairos-cli deposit --amount 1000 --private-key ${testResources}/ed25519/secret_key.pem")
Expand Down

0 comments on commit 9f5cbb4

Please sign in to comment.