Skip to content

Commit

Permalink
test: added test snapshot for mint
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven2505 committed Jan 21, 2025
1 parent 5445fd0 commit af0c64a
Show file tree
Hide file tree
Showing 34 changed files with 38 additions and 26 deletions.
24 changes: 5 additions & 19 deletions src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
#include "plugin.h"

static void handle_delegate(ethPluginProvideParameter_t *msg, context_t *context) {
switch (context->next_param) {
case BENEFICIARY:
copy_address(context->beneficiary, msg->parameter, sizeof(context->beneficiary));
context->next_param = NONE;
break;
case NONE:
break;
default:
PRINTF("Param not supported: %d\n", context->next_param);
msg->result = ETH_PLUGIN_RESULT_ERROR;
break;
}
}

static void handle_create_reward_vault(ethPluginProvideParameter_t *msg, context_t *context) {
static void handle_beneficiary(ethPluginProvideParameter_t *msg, context_t *context) {
switch (context->next_param) {
case BENEFICIARY:
copy_address(context->beneficiary, msg->parameter, sizeof(context->beneficiary));
Expand Down Expand Up @@ -45,6 +30,9 @@ static void handle_mint(ethPluginProvideParameter_t *msg, context_t *context) {
context->next_param = BOOLEAN;
break;
case BOOLEAN:
if (!U2BE_from_parameter(msg->parameter, &context->boolean)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
context->next_param = NONE;
break;
case NONE:
Expand All @@ -71,10 +59,8 @@ void handle_provide_parameter(ethPluginProvideParameter_t *msg) {
// EDIT THIS: adapt the cases and the names of the functions.
switch (context->selectorIndex) {
case CREATE_REWARD_VAULT:
handle_create_reward_vault(msg, context);
break;
case DELEGATE:
handle_delegate(msg, context);
handle_beneficiary(msg, context);
break;
case MINT:
handle_mint(msg, context);
Expand Down
25 changes: 24 additions & 1 deletion src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ static bool set_address_ui(ethQueryContractUI_t *msg, context_t *context) {
chainid);
}

static bool set_boolean_ui(ethQueryContractUI_t *msg, context_t *context) {
switch (context->selectorIndex) {
case MINT:
strlcpy(msg->title, "Basket Mode", msg->titleLength);
break;
default:
PRINTF("Received an invalid selectorIndex\n");
break;
}

if (context->boolean == 0) {
snprintf(msg->msg, msg->msgLength, "%s", "False");
return true;
} else {
snprintf(msg->msg, msg->msgLength, "%s", "True");
return true;
}
return false;
}

void handle_query_contract_ui(ethQueryContractUI_t *msg) {
context_t *context = (context_t *) msg->pluginContext;
bool ret = false;
Expand Down Expand Up @@ -128,11 +148,14 @@ void handle_query_contract_ui(ethQueryContractUI_t *msg) {
ret = set_address_ui(msg, context);
break;
case 1:
ret = set_min_amount_received_ui(msg, context);
ret = set_receive_ui(msg, context);
break;
case 2:
ret = set_beneficiary_ui(msg, context);
break;
case 3:
ret = set_boolean_ui(msg, context);
break;
default:
PRINTF("Received an invalid screenIndex\n");
break;
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define SELECTORS_LIST(X) \
X(CREATE_REWARD_VAULT, 0x577ee5c7) \
X(DELEGATE, 0x5c19a95c) \
X(MINT, 0x0d4d1513)
X(MINT, 0x328ebaf7)

// Xmacro helpers to define the enum and map
// Do not modify !
Expand Down Expand Up @@ -72,7 +72,7 @@ typedef struct context_s {
char ticker[MAX_TICKER_LEN];
uint8_t decimals;
uint8_t token_found;
bool boolean;
uint16_t boolean;
// For parsing data.
uint8_t next_param; // Set to be the next param we expect to parse.
uint16_t offset; // Offset at which the array or struct starts.
Expand Down
Binary file added tests/snapshots/flex/test_mint/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/flex/test_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/flex/test_mint/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/flex/test_mint/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/flex/test_mint/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/flex/test_mint/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanosp/test_mint/00008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox/test_mint/00008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/stax/test_mint/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/stax/test_mint/00001.png
Binary file added tests/snapshots/stax/test_mint/00002.png
Binary file added tests/snapshots/stax/test_mint/00003.png
Binary file added tests/snapshots/stax/test_mint/00004.png
Binary file added tests/snapshots/stax/test_mint/00005.png
11 changes: 7 additions & 4 deletions tests/test_mint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
PLUGIN_NAME = get_appname_from_makefile()


with open("%s/0x289274787baf083c15a45a174b7a8e44f0720660.abi.json" % (ABIS_FOLDER)) as file:
with open("%s/0xb05b8099d9de1e5cf07cd135d059d5a5ed484388.abi.json" % (ABIS_FOLDER)) as file:
contract = Web3().eth.contract(
abi=json.load(file),
# Get address from filename
Expand All @@ -28,11 +28,14 @@


# EDIT THIS: build your own test
def test_delegate(backend, firmware, navigator, test_name, wallet_addr):
def test_mint(backend, firmware, navigator, test_name, wallet_addr):
client = EthAppClient(backend)

data = contract.encode_abi("delegate", [
bytes.fromhex("0be5debae3edfedd42f420247847d2a6f0fa598f")
data = contract.encode_abi("mint", [
bytes.fromhex("015fd589F4f1A33ce4487E12714e1B15129c9329"),
Web3.to_wei(1.13, "ether"),
bytes.fromhex("4C368fFE3650379d6318C8d4630bc51f8Ad12bB6"),
False,
])

# first setup the external plugin
Expand Down

0 comments on commit af0c64a

Please sign in to comment.