Skip to content

Commit

Permalink
fix testcases for Monacoin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mona Tore authored and visvirial committed Dec 11, 2014
1 parent 689f4a9 commit 4ff1957
Show file tree
Hide file tree
Showing 59 changed files with 624 additions and 135 deletions.
2 changes: 1 addition & 1 deletion examples/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var Address = bitcore.Address;

var addrs = [
Expand Down
2 changes: 1 addition & 1 deletion examples/CreateAndSignTx-Multisig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var run = function() {
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
bitcore = typeof(bitcore) === 'undefined' ? require('../monacore') : bitcore;
var networks = require('../networks');
var WalletKey = bitcore.WalletKey;
var Builder = bitcore.TransactionBuilder;
Expand Down
2 changes: 1 addition & 1 deletion examples/CreateAndSignTx-PayToPubkeyHash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var run = function() {
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
bitcore = typeof(bitcore) === 'undefined' ? require('../monacore') : bitcore;

var priv = 'cTgGUrcro89yUtKeG6gHBAS14r3qp25KwTTxG9d4kEzcFxecuZDm';
var amt = '0.005';
Expand Down
2 changes: 1 addition & 1 deletion examples/CreateAndSignTx-PayToScriptHash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var run = function() {
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
bitcore = typeof(bitcore) === 'undefined' ? require('../monacore') : bitcore;
var networks = require('../networks');
var WalletKey = bitcore.WalletKey;
var Script = bitcore.Script;
Expand Down
2 changes: 1 addition & 1 deletion examples/CreateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var run = function() {
// replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var networks = require('../networks');
var WalletKey = bitcore.WalletKey;

Expand Down
2 changes: 1 addition & 1 deletion examples/CreateScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var run = function() {
// replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var networks = require('../networks');
var Script = bitcore.Script;
var WalletKey = bitcore.WalletKey;
Expand Down
2 changes: 1 addition & 1 deletion examples/ECIES.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var run = function() {
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
bitcore = typeof(bitcore) === 'undefined' ? require('../monacore') : bitcore;

console.log('ECIES: Elliptic Curve Integrated Encryption Scheme');
console.log('A way of encrypting with a public key and decrypting with a private key.');
Expand Down
2 changes: 1 addition & 1 deletion examples/HierarchicalKey.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var run = function() {
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
bitcore = typeof(bitcore) === 'undefined' ? require('../monacore') : bitcore;
var HierarchicalKey = bitcore.HierarchicalKey;
var Address = bitcore.Address;
var networks = bitcore.networks;
Expand Down
2 changes: 1 addition & 1 deletion examples/NetworkMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var NetworkMonitor = bitcore.NetworkMonitor;

var config = {
Expand Down
1 change: 0 additions & 1 deletion examples/PayPro/bitcore.js

This file was deleted.

490 changes: 490 additions & 0 deletions examples/PayPro/bitcore.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/PayToScriptHashAddress.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var Address = bitcore.Address;
var bitcoreUtil = bitcore.util;
var Script = bitcore.Script;
Expand Down
2 changes: 1 addition & 1 deletion examples/PeerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var Peer = bitcore.Peer;
var PeerManager = bitcore.PeerManager;

Expand Down
2 changes: 1 addition & 1 deletion examples/Rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var RpcClient = bitcore.RpcClient;
var hash = '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';

Expand Down
2 changes: 1 addition & 1 deletion examples/Script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var Address = bitcore.Address;
var coinUtil = bitcore.util;
var Script = bitcore.Script;
Expand Down
2 changes: 1 addition & 1 deletion examples/ScriptInterpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var Address = bitcore.Address;
var coinUtil = bitcore.util;
var Script = bitcore.Script;
Expand Down
2 changes: 1 addition & 1 deletion examples/SendTx.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var Peer = bitcore.Peer;

var TransactionBuilder = bitcore.TransactionBuilder;
Expand Down
2 changes: 1 addition & 1 deletion examples/VanityAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var bitcore = require('../monacore');
var Key = bitcore.Key;
var Address = bitcore.Address;

Expand Down
38 changes: 19 additions & 19 deletions test/data/base58_keys_valid.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
[
"1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i",
"MHAXoRyxuYLNNME44GgeMpdYrguTbbR9xu",
"65a16059864a2fdbc7c99a4723a8395bc6f188eb",
{
"addrType": "pubkey",
Expand Down Expand Up @@ -36,7 +36,7 @@
}
],
[
"5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr",
"6zpGBmumEkc2j1i3ZvXJfBnu7fEr38MvbJwMcYs9GhA2mM1ctBS",
"eddbdc1168f1daeadbd3e44c1e3f8f5a284c2029f78ad26af98583a499de5b19",
{
"isCompressed": false,
Expand All @@ -45,7 +45,7 @@
}
],
[
"Kz6UJmQACJmLtaQj5A3JAge4kVTNQ8gbvXuwbmCj7bsaabudb3RD",
"TP5ztqR8wzaDcT58iwmwyPNRCDVz94Ex4d4TaUXTfXZAf9pZxb47",
"55c9bccb9ed68446d1b75273bbce89d7fe013a8acd1625514420fb2aca1a21c4",
{
"isCompressed": true,
Expand All @@ -72,7 +72,7 @@
}
],
[
"1Ax4gZtb7gAit2TivwejZHYtNNLT18PUXJ",
"MHrDuznzchLXmhS49vJfoZADqbDcdLDmFj",
"6d23156cbbdcc82a5a47eee4c2c7c583c18b6bf4",
{
"addrType": "pubkey",
Expand Down Expand Up @@ -108,7 +108,7 @@
}
],
[
"5K494XZwps2bGyeL71pWid4noiSNA2cfCibrvRWqcHSptoFn7rc",
"6zFMt81YS8qv1zhbRzrUQf3WbREGfEkSYg9F7uufK3nDZzY7WH2",
"a326b95ebae30164217d7a7f57d72ab2b54e3be64928a19da0210b9568d4015e",
{
"isCompressed": false,
Expand All @@ -117,7 +117,7 @@
}
],
[
"L1RrrnXkcKut5DEMwtDthjwRcTTwED36thyL1DebVrKuwvohjMNi",
"TQRPSrYjN1iko5tmbfxYWSfn4BWYy8bT2o7qyvyL3n1W2UhTrJV4",
"7d998b45c219a1e38e99e7cbd312ef67f77a455a9b50c730c27f02c6f730dfb4",
{
"isCompressed": true,
Expand All @@ -144,7 +144,7 @@
}
],
[
"1C5bSj1iEGUgSTbziymG7Cn18ENQuT36vv",
"MJykg9v7jHeVL8aKwxRCMUPLbTFaUxRu6V",
"7987ccaa53d02c8873487ef919677cd3db7a6912",
{
"addrType": "pubkey",
Expand Down Expand Up @@ -180,7 +180,7 @@
}
],
[
"5KaBW9vNtWNhc3ZEDyNCiXLPdVPHCikRxSBWwV9NrpLLa4LsXi9",
"6zmQKkMyVnC2M4cVYxQAQZK7RCBBhvtDJPiu8yYCZafjFDQdudh",
"e75d936d56377f432f404aabb406601f892fd49da90eb6ac558a733c93b47252",
{
"isCompressed": false,
Expand All @@ -189,7 +189,7 @@
}
],
[
"L1axzbSyynNYA8mCAhzxkipKkfHtAXYF4YQnhSKcLV8YXA874fgT",
"TQaVafTxjUBQt1RbpVjcZRYgCPLVuT6bCdZJg9eLtQp8bi5DUsJ6",
"8248bd0375f2f75d7e274ae544fb920f51784480866b102384190b1addfbaa5c",
{
"isCompressed": true,
Expand All @@ -216,7 +216,7 @@
}
],
[
"1Gqk4Tv79P91Cc1STQtU3s1W6277M2CVWu",
"MPjuHtpWeQJp6GymgPYQJ8cqZEzGt2LLxc",
"adc1cc2081a27206fae25792f28bbc55b831549d",
{
"addrType": "pubkey",
Expand Down Expand Up @@ -252,7 +252,7 @@
}
],
[
"5HtH6GdcwCJA4ggWEL1B3jzBBUB8HPiBi9SBc5h9i4Wk4PSeApR",
"6y5Vus5DYU7UohjmZK38jmxtyAy2nbqy46yZoa5yQpr8jRbkuik",
"091035445ef105fa1bb125eccfb1882f3fe69592265956ade751fd095033d8d0",
{
"isCompressed": false,
Expand All @@ -261,7 +261,7 @@
}
],
[
"L2xSYmMeVo3Zek3ZTsv9xUrXVAmrWxJ8Ua4cw8pkfbQhcEFhkXT8",
"TRwy8qNdFUrSNchy7feomBasvtpUFsrUcfD8ur9VDX6HgnGY3Nnt",
"ab2b4bcdfc91d34dee0ae2a8c6b6668dadaeb3a88b9859743156f462325187af",
{
"isCompressed": true,
Expand All @@ -288,7 +288,7 @@
}
],
[
"1JwMWBVLtiqtscbaRHai4pqHokhFCbtoB4",
"MRqWjcPkPk1hmHZueGEeK6SdGyaQpNYuyr",
"c4c1b72491ede1eedaca00618407ee0b772cad0d",
{
"addrType": "pubkey",
Expand Down Expand Up @@ -324,7 +324,7 @@
}
],
[
"5KQmDryMNDcisTzRp3zEq9e4awRmJrEVU1j5vFRTKpRNYPqYrMg",
"6zbz3TQwyVS3cV3h932CXBcnNeDfp4NGoyGU7jpH2akmDQqg8rV",
"d1fab7ab7385ad26872237f1eb9789aa25cc986bacc695e07ac571d6cdac8bc0",
{
"isCompressed": false,
Expand All @@ -333,7 +333,7 @@
}
],
[
"L39Fy7AC2Hhj95gh3Yb2AU5YHh1mQSAHgpNixvm27poizcJyLtUi",
"TS8nZBBAmyWbrxM6hLKfyAotjR4P9MidpuXEwe5kfkVK5ADL2j4a",
"b0bbede33ef254e8376aceb1510253fc3550efd0fcf84dcd0c9998b288f166b3",
{
"isCompressed": true,
Expand All @@ -360,7 +360,7 @@
}
],
[
"19dcawoKcZdQz365WpXWMhX6QCUpR9SY4r",
"MGXmpNhj7aoDsi4QjoBSby8RsRMyuND3iU",
"5eadaf9bb7121f0f192561a5a62f5e5f54210292",
{
"addrType": "pubkey",
Expand Down Expand Up @@ -396,7 +396,7 @@
}
],
[
"5KL6zEaMtPRXZKo1bbMq7JDjjo1bJuQcsgL33je3oY8uSJCR5b4",
"6zXKoq1xVfErJLrGvaPnoLCTXVoVp7YQDdsRFE2sWJUJ7LvEmLb",
"c7666842503db6dc6ea061f092cfb9c388448629a6fe868d068c42a488b478ae",
{
"isCompressed": false,
Expand All @@ -405,7 +405,7 @@
}
],
[
"KwV9KAfwbwt51veZWNscRTeZs9CKpojyu1MsPnaKTF5kz69H1UN2",
"TLUfuEgvMdgwjoJyAAcGEANvJsEwZjJL36WPNVu41AmM4eA7ZQU2",
"07f0803fc5399e773555ab1e8939907e9badacc17ca129e67a2f5f2ff84351dd",
{
"isCompressed": true,
Expand All @@ -432,7 +432,7 @@
}
],
[
"13p1ijLwsnrcuyqcTvJXkq2ASdXqcnEBLE",
"MAiAxAFMNp2RoeowgtxU16dVurR1CYdyCK",
"1ed467017f043e91ed4c44b4e8dd674db211c4e6",
{
"addrType": "pubkey",
Expand Down
24 changes: 12 additions & 12 deletions test/test.Address.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var chai = chai || require('chai');
var bitcore = bitcore || require('../bitcore');
var bitcore = bitcore || require('../monacore');

var should = chai.should();
var expect = chai.expect;
Expand All @@ -23,12 +23,12 @@ describe('Address', function() {
a.toString().should.equal('1GfGL3iLTfX43KSCd95WhMi4bgU36qjzC1');
});
var data = [
['1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', true],
['MGv9cSYnaRSTZNzYaN7bhbgmozoGkKBvCn', true],
['11111111111111111111111111122222234', false], // totally invalid
['32QBdjycLwbDTuGafUwaU5p5GxzSLPYoF6', true],
['1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9', true],
['MWuyTWpnmFQAj6apeLFpRajPVkyZXCTXYQ', true],
['1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNb', false], //bad checksum ... thanks @wtogami
['1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i', true],
['MHAXoRyxuYLNNME44GgeMpdYrguTbbR9xu', true],
['1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW600', false], // bad checksum
['1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW620', false], // bad checksum
['1ANNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i', false], // data changed, original checksum.
Expand Down Expand Up @@ -56,9 +56,9 @@ describe('Address', function() {
});
it('should be able to detect network from an address', function() {
// livenet
var a = new Address('1KfyjCgBSMsLqiCbakfSdeoBUqMqLUiu3T');
var a = new Address('MSa8xdaawP39jPAvojKNsvQWx4EzvYUMeE');
a.network().name.should.equal('livenet');
a = new Address('1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp');
a = new Address('M8Xsr52draweDbpbT34YPs5b8NGgfjGW6n');
a.network().name.should.equal('livenet');
//p2sh
a = new Address('3QRhucKtEn5P9i7YPxzXCqBtPJTPbRFycn');
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('Address', function() {
key.private = privkey;
key.regenerateSync();
var hash = bitcore.util.sha256ripe160(key.public);
var addr = new bitcore.Address(0, hash);
var addr = new bitcore.Address(50, hash);
addr.isValid().should.equal(true);
});

Expand All @@ -113,13 +113,13 @@ describe('Address', function() {
describe('constructor, 2 params', function() {
it('should make an address from a version, hash', function() {
var hash = new Buffer('1ab59a0fd1d5fc446d38746ee033c8af57ed6bc0', 'hex');
var addr = new Address(0, hash);
addr.toString().should.equal('13SE7uKmnQwGA8X1A8WcZnX2ceQRDEzsAd');
var addr = new Address(50, hash);
addr.toString().should.equal('MALPMLEBHS753oVLP7AYp48N5sHao5G6We');
});
it('should fail with param version, string', function() {
var hash = '1ab59a0fd1d5fc446d38746ee033c8af57ed6bc0';
(function() {
var addr = new Address(0, hash);
var addr = new Address(50, hash);
}).should.throw();
});
});
Expand All @@ -129,7 +129,7 @@ describe('Address', function() {
it('should make pubkeyhash address from an uncompressed public key', function() {
var pubkey = new Buffer('04fa05ce8b25010cb6e17a30e0b66668bf083c40687547748ec330ee77adf53a42abd3d26148cbacfcf79c907ddefeb2c37f8bebc0a695ba79d634449d871de218', 'hex');
var hash = bitcore.util.sha256ripe160(pubkey);
var addr = new Address(0, hash);
var addr = new Address(50, hash);
addr.toString().should.equal(Address.fromPubKey(pubkey).toString());
});
});
Expand All @@ -140,7 +140,7 @@ describe('Address', function() {
k.compressed = true;
k.regenerateSync();
var a = Address.fromKey(k);
a.toString().should.equal('1L8k7WpWHMNkqVPTaZhzFU5VaWyjZEK7mD');
a.toString().should.equal('MT2uLwiunNYZjAMnoYMvVjgq3jru9K1UmH');
});
});

Expand Down
Loading

0 comments on commit 4ff1957

Please sign in to comment.