-
Notifications
You must be signed in to change notification settings - Fork 16
EN DApps Reference
Require path: modules/logger
logger provides standardized output to the console.
Property: disable - true - disable message output; false - enable output
new Logger([prefix])
Args:
- prefix (string) – Messages prefix
getPrefix()
Returns: Prefix value
log(type, data)
Args:
- type (string) – Message type
- data (string) – Message
info(data)
Args:
- data (string) – Info message
init(data)
Args:
- data (string) – Init message
error(data)
Args:
- data (string) – Error message
fatal(data)
Args:
- data (string) – Fatal error message
warning(data)
Args:
- data (string) – Warning message
Example:
const DApp = require(global.PATH.mainDir + '/app/DApp');
const logger = new (require(global.PATH.mainDir + '/modules/logger'))("TestDApp");
class TestDApp extends DApp {
init(){
logger.info('Test DApp ready!'); //Prints "Fri, 01 Feb 2019 14:12:48 GMT Info: TestDApp: Test DApp ready"
}
}
Require path: modules/testing/assert
The implementation is identical to the implementation inside EcmaContract environment.
Provides functionality for checking any conditions. Failure to comply with these conditions leads to the throwing of an exception and termination of the contract/DApp call with an error. For the contracts the state is rolled back to the state before the call.
Assertion for statement is equals to true
assert(statement[, message])
Args:
- statement – Checking statement
- message – Message if statement are incorrect
Throws: Exception
Check is element defined
defined(statement[, message])
Args:
- statement – Checking statement
- message – Message if statement are incorrect
Throws: Exception
Checks is a > b
gt(a, b[, message])
Args:
- a – First element
- b – Second element
- message – Message if statement are incorrect
Throws: Exception
Checks is a < b
lt(a, b[, message])
Args:
- a – First element
- b – Second element
- message – Message if statement are incorrect
Throws: Exception
Assertion for statement is equals to true. Alias for assert
true(statement[, message])
Args:
- statement – Checking statement
- message – Message if statement are incorrect
Throws: Exception
Assertion for statement is equals to false.
false(statement[, message])
Args:
- statement – Checking statement
- message – Message if statement are incorrect
Throws: Exception
Example:
class Test extends Contract {
init(){
super.init();
assert.gt(100,200,'100 can\'t be greather than 200');
}
}