diff --git a/src/scripts/init_blockchain.sh b/src/scripts/init_blockchain.sh index b44a19b..3791dc5 100755 --- a/src/scripts/init_blockchain.sh +++ b/src/scripts/init_blockchain.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -o errexit +# set -o errexit echo "=== lamington: setup blockchain accounts and smart contract ===" @@ -15,7 +15,7 @@ rm -rf /mnt/dev/data # run it in a background job such that docker run could continue nodeos -e -p eosio -d /mnt/dev/data \ --config-dir /mnt/dev/config \ - --max-transaction-time=1000 \ + --max-transaction-time=5000 \ --http-validate-host=false \ --plugin eosio::producer_plugin \ --plugin eosio::producer_api_plugin \ diff --git a/src/utils.ts b/src/utils.ts index dccd45f..afba2c9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -6,7 +6,6 @@ import * as deepEqualInAnyOrder from 'deep-equal-in-any-order'; import { EOSManager } from './eosManager'; import { verbose_logging } from './cli/lamington-test'; import { TableRowsResult } from './contracts'; -import { verbose_logging } from './cli/lamington-test'; // Extend Chai's expect methods chai.use(deepEqualInAnyOrder); @@ -201,8 +200,12 @@ export const assertEOSError = async ( * @param operation Operation promise * @param message Output message expected to be included */ -export const assertEOSErrorIncludesMessage = async (operation: Promise, message: string) => { - const eosErrorName = 'eosio_assert_message_exception'; +export const assertEOSErrorIncludesMessage = async ( + operation: Promise, + message: string, + errorName?: string +) => { + const eosErrorName = errorName || 'eosio_assert_message_exception'; // Execute operation and handle exceptions if ( !(await assertExpectedEOSError(operation, eosErrorName, error => { @@ -226,53 +229,12 @@ export const assertEOSErrorIncludesMessage = async (operation: Promise, mes } }; -/** - - * Asserts EOS throws an error and validates the error output name matches the - * expected 'eosio_assert_message_exception' and the error message includes `description` - * @author Dallas Johnson - * @param operation Operation promise - * @param description Output message description - */ - -export const assertEOSErrorIncludesMessage = async (operation: Promise, message: string) => { - const eosErrorName = 'eosio_assert_message_exception'; - // Execute operation and handle exceptions - try { - await operation; - } catch (error) { - let errorMessage = error.json.error.details[0].message; - if (verbose_logging) { - console.log('full error message: ' + JSON.stringify(error, null, 4)); - } - if (error.json && error.json.error && error.json.error.name && errorMessage) { - // Compare error and fail if the error doesn't match the expected - assert( - error.json.error.name === eosErrorName, - `Expected ${eosErrorName}, got ${error.json.error.name} instead.` - ); - assert( - errorMessage.includes(message), - `Expected to include ${message}, got ${errorMessage} instead.` - ); - return; - } else { - // Fail if error not thrown by EOS - assert.fail( - `Expected EOS error ${eosErrorName}, but got ${JSON.stringify(error, null, 4)} instead.` - ); - } - } - // Fail if no exception thrown - assert.fail(`Expected ${eosErrorName} but operation completed successfully.`); -}; - /** * Asserts operation throws an `eosio_assert_message_exception` error * @author Kevin Brown * @param operation Operation promise */ -export const assertEOSException = (operation: Promise) => +export const assertEOSException = async (operation: Promise) => assertEOSError(operation, 'eosio_assert_message_exception', 'assert'); /** @@ -280,5 +242,5 @@ export const assertEOSException = (operation: Promise) => * @author Kevin Brown * @param operation Operation promise */ -export const assertMissingAuthority = (operation: Promise) => - assertEOSError(operation, 'missing_auth_exception', 'missing authority'); +export const assertMissingAuthority = async (operation: Promise) => + assertEOSErrorIncludesMessage(operation, '', 'missing_auth_exception');