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

Tests of nodes that use config nodes that implement RED.httpAdmin.get(… fail #33

Open
jorisadri opened this issue Mar 22, 2019 · 0 comments

Comments

@jorisadri
Copy link

When testing nodes that use a config node that implements RED.httpAdmin.get(…, the tests fail.
When doing helper.getNode("node1")
It fails with this error:

TypeError: Cannot read property ‘get’ of null
at Array.module.exports  (location to line number with RED.httpAdmin.get(…  ) 
at Object.load (node_modules/node-red-node-test-helper/index.js:131:28)
at Context.<anonymous> (to location of the helper.load(<node that implements the config>))

Code of the config

module.exports = function (RED) {
    const { Account, PublicAccount, NetworkType } = require('nem2-sdk');
    function accountConfig(config) {
        RED.nodes.createNode(this, config);
        this.name = config.name;
        this.privateKey = config.privateKey;
        this.publicKey = config.publicKey;
        this.address = config.address;
        this.network = RED.nodes.getNode(config.network).network
    }
    RED.nodes.registerType("accountConfig", accountConfig);
    RED.httpAdmin.get("/accountinfo", RED.auth.needsPermission('accountConfig.read'), function (req, res) {
        const network = RED.nodes.getNode(req.query.network).network
        let publicKey = req.query.privateKey ? Account.createFromPrivateKey(req.query.privateKey, NetworkType[network]).publicKey : req.query.publicKey;
        let address = publicKey ? PublicAccount.createFromPublicKey(publicKey, NetworkType[network]).address.plain() : req.query.address;
        res.json({ publicKey: publicKey, address: address });
    });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant