Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update e2e #59

Merged
merged 6 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading