OmniLayer / OmniClientJS

(Unmaintained) Omni Layer Node.js RPC client (bitcoind + omnicored extensions)
90 stars 45 forks source link

OmniTests.js doesn't start #1

Open dexX7 opened 8 years ago

dexX7 commented 8 years ago

When trying to run OmniTests.js, then the following exception is thrown:

module.js:340
    throw err;
          ^
Error: Cannot find module './Exchanges/OmniRPC.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/root/OmniTradeJS/OmniTests.js:1:74)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

When renaming and moving omnirpc.js into ./Exchanges/OmniRPC.js, and starting OmniTests.js, the following errors pop up:


/root/OmniTradeJS/Exchanges/OmniRPC.js:52
function call(rpcMethod, params){
^^^^^^^^
SyntaxError: Unexpected token function
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/root/OmniTradeJS/OmniTests.js:1:74)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
msgilligan commented 8 years ago

Hi @dexX7 ,

You might want to try it again with 9c6666b7a7d01e59feb6ee95d7c97d71c6c03aaf which moves OmniRPC.js into Exchanges, adds instructions to the README, includes a package.json file (and I previously merged in @patrickdugan 's pull request.)

dexX7 commented 8 years ago

Hmm.. it seems to work, more or less. These are the changes I made:

root@ubuntu-1gb-fra1-01:~/OmniTradeJS# git diff
diff --git a/Exchanges/OmniRPC.js b/Exchanges/OmniRPC.js
index 58be38d..0b650d6 100644
--- a/Exchanges/OmniRPC.js
+++ b/Exchanges/OmniRPC.js
@@ -1,7 +1,7 @@
 var bitcoin = require('bitcoin');

-var user = '<your user here>'
-var pass = '<your password here>'
+var user = 'bitcoinrpc'
+var pass = 'pass'

 var Omni = {}

diff --git a/OmniTests.js b/OmniTests.js
index a8d3a63..8ced995 100644
--- a/OmniTests.js
+++ b/OmniTests.js
@@ -14,7 +14,7 @@ var addresses = []

 var suffixes = ['credits','peso','dollar','yuan','yen','pound','schilling','won']

-var address = "n4Po8andi3akpQBxzBWXbQBttF9LueXqyo"
+var address = "mwaDr5GEJER133FJJKaUB6Rg7DbGXa6JYa"

 var address2 = ''

When running:

root@ubuntu-1gb-fra1-01:~/OmniTradeJS# node OmniTests.js

Then it stops here without further output:

{ '': 0.0149 }
{ '': 0.0149 }
{ [Error: value is type int, expected str] code: -1 }
[]

edit: after some time:

[ { propertyid: 1, balance: '1.00000000', reserved: '0.00000000' },
  { propertyid: 2, balance: '1.00000000', reserved: '0.00000000' } ]

To provide some further information: I funded mwaDr5GEJER133FJJKaUB6Rg7DbGXa6JYa via testnet faucets and sent some coins to the moneyman address in exchange for Omni.

msgilligan commented 8 years ago

@dexX7 You might want to check the latest commits I made and look at the README.

dexX7 commented 8 years ago

I visually inspected the latest commits, and the direction looks very good! But haven't tested it yet, and it looks like this won't resolve my issue.

The connection to Omni Core was successfully established during the earlier tries, but it basically comes down to error messages without providing the context, which makes it difficult to me to pin down the actual issue (see post above).

It could be helpful to debug print step by step (e.g. "trade x y z"), and in case of errors, also dump the JSON error message. Though I should probably fire up some debugger and step through the code..