Skip to content

Commit

Permalink
Update transaction test cases (#42)
Browse files Browse the repository at this point in the history
* Add JS code to generate transaction test vectors

* Update tests to use new testvectors

* Update CONTRACT_HASH_ADD_NEW_KEY

* Update test cases to use public keys

* Fix JSON test cases

* Remove test cases with multiple authorizers

* Improve test cases to include wider range of account key values

* Fix test names

* Compute account key buffer size as constant

* Update parser.c

* Update transaction example blobs for zemu tests

* Fix multi-line macro

* Fix transaction test cases

* Adjust FLOW_ACCOUNT_KEY_SIZE

* Update parser.c

* Update parser.c

* Update parser.c

* Update parser.c

* Update parser.c

* Update test.js

* Revert "Update test.js"

This reverts commit 0f5aaa2c71e714808d5885194b2d82d191e5d95d.

* update zemu screenshots

Co-authored-by: Juan Leni <juan.leni@zondax.ch>
  • Loading branch information
psiemens and jleni authored Sep 9, 2020
1 parent 179794f commit 4a8936c
Show file tree
Hide file tree
Showing 147 changed files with 4,101 additions and 5,664 deletions.
4 changes: 2 additions & 2 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ COIN=FLOW
endif

APPVERSION_M=0
APPVERSION_N=7
APPVERSION_P=3
APPVERSION_N=8
APPVERSION_P=0

$(info COIN = [$(COIN)])
ifeq ($(COIN),FLOW)
Expand Down
2 changes: 1 addition & 1 deletion app/src/coin_script_hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern "C" {

#define CONTRACT_HASH_TOKEN_TRANSFER "ca80b628d985b358ae1cb136bcd976997c942fa10dbabfeafb4e20fa66a5a5e2"
#define CONTRACT_HASH_CREATE_ACCOUNT "eef2d0494448554177612e63026256258339230cbc6931ded78d6149443c6173"
#define CONTRACT_HASH_ADD_NEW_KEY "9f2e43f75e6f001879c66b16137e3cddbe3adeb56c1915831022babe84d6b0ee"
#define CONTRACT_HASH_ADD_NEW_KEY "595c86561441b32b2b91ee03f9e10ca6efa7b41bcc994f51317ec0aa9d8f8a42"

#ifdef __cplusplus
}
Expand Down
18 changes: 15 additions & 3 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ void __assert_fail(const char * assertion, const char * file, unsigned int line,
}
#endif

#define FLOW_PUBKEY_SIZE 150
#define FLOW_PUBLIC_KEY_SIZE 64 // 64 bytes for public key
#define FLOW_SIG_ALGO_SIZE 1 // 8 bits for signature algorithm (uint8)
#define FLOW_HASH_ALGO_SIZE 1 // 8 bits for hash algorithm (uint8)
#define FLOW_WEIGHT_SIZE 2 // 16 bits for weight (uint16)
#define RLP_PREFIX 1

#define FLOW_ACCOUNT_KEY_SIZE (2 * ( \
(RLP_PREFIX * 2) + \
((RLP_PREFIX * 2) + FLOW_PUBLIC_KEY_SIZE) + \
(RLP_PREFIX + FLOW_SIG_ALGO_SIZE) + \
(RLP_PREFIX + FLOW_HASH_ALGO_SIZE) + \
(RLP_PREFIX + FLOW_WEIGHT_SIZE) \
) + 2)

parser_error_t parser_parse(parser_context_t *ctx, const uint8_t *data, size_t dataLen) {
CHECK_PARSER_ERR(parser_init(ctx, data, dataLen))
Expand Down Expand Up @@ -88,7 +100,7 @@ parser_error_t parser_printArgumentPublicKey(const parser_context_t *argumentCtx
parsed_json_t parsedJson = {false};
CHECK_PARSER_ERR(json_parse(&parsedJson, (char *) argumentCtx->buffer, argumentCtx->bufferLen));

char bufferUI[FLOW_PUBKEY_SIZE];
char bufferUI[FLOW_ACCOUNT_KEY_SIZE];
CHECK_PARSER_ERR(json_extractPubKey(bufferUI, sizeof(bufferUI), &parsedJson, 0))
pageString(outVal, outValLen, bufferUI, pageIdx, pageCount);

Expand Down Expand Up @@ -120,7 +132,7 @@ parser_error_t parser_printArgumentPublicKeys(const parser_context_t *argumentCt
zemu_log_stack("PublicKeys");

uint16_t arrayElementToken;
char bufferUI[FLOW_PUBKEY_SIZE];
char bufferUI[FLOW_ACCOUNT_KEY_SIZE];
CHECK_PARSER_ERR(array_get_nth_element(&parsedJson, internalTokenElementIdx, argumentIndex, &arrayElementToken))
CHECK_PARSER_ERR(json_extractPubKey(bufferUI, sizeof(bufferUI), &parsedJson, arrayElementToken))
pageString(outVal, outValLen, bufferUI, pageIdx, pageCount);
Expand Down
72 changes: 72 additions & 0 deletions tests/generate-transaction-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

\.idea/

.vscode

TODO\.md

\dist
/certs/cert.pem
/certs/server.cert
/certs/server.key
Loading

0 comments on commit 4a8936c

Please sign in to comment.