<commit_before>var assert = require('assert');
var fs = require('fs');

var Address = require('../Address').class();
var networks = require('../networks');

suite('basic');

function test_encode_priv(b58, payload, isTestnet)
{
}

function test_encode_pub(b58, payload, isTestnet, addrType)
{
	var isScript = (addrType == 'script');
	var network = isTestnet ? networks.testnet : networks.livenet;
	var version = isScript ? network.addressScript : network.addressPubkey;
	var buf = new Buffer(payload, 'hex');
	var addr = new Address(version, buf);
	assert.equal(addr.toString(), b58);
}

function test_decode_priv(b58, payload, isTestnet)
{
}

function test_decode_pub(b58, payload, isTestnet, addrType)
{
	var isScript = (addrType == 'script');
	var network = isTestnet ? networks.testnet : networks.livenet;
	var version = isScript ? network.addressScript : network.addressPubkey;
	var buf = new Buffer(payload, 'hex');
	var addr = new Address(b58);

	assert.equal(version, addr.version());
	assert.equal(buf.toString(), addr.hash().toString());
}

function is_valid(datum)
{
	var b58 = datum[0];
	var payload = datum[1];
	var obj = datum[2];
	var isPrivkey = obj['isPrivkey'];
	var isTestnet = obj['isTestnet'];

	if (isPrivkey) {
		test_encode_priv(b58, payload, isTestnet);
		test_decode_priv(b58, payload, isTestnet);
	} else {
		var addrType = obj['addrType'];
		test_encode_pub(b58, payload, isTestnet, addrType);
		test_decode_pub(b58, payload, isTestnet, addrType);
	}
}

function is_invalid(datum)
{
}

var dataValid = JSON.parse(fs.readFileSync('test/base58_keys_valid.json'));
var dataInvalid = JSON.parse(fs.readFileSync('test/base58_keys_invalid.json'));

test('valid', function() {
	dataValid.forEach(function(datum) { is_valid(datum); });
});<commit_msg>test/basic: fix test for VersionedData updates, s/hash/payload/<commit_after>var assert = require('assert');
var fs = require('fs');

var Address = require('../Address').class();
var networks = require('../networks');

suite('basic');

function test_encode_priv(b58, payload, isTestnet)
{
}

function test_encode_pub(b58, payload, isTestnet, addrType)
{
	var isScript = (addrType == 'script');
	var network = isTestnet ? networks.testnet : networks.livenet;
	var version = isScript ? network.addressScript : network.addressPubkey;
	var buf = new Buffer(payload, 'hex');
	var addr = new Address(version, buf);
	assert.equal(addr.toString(), b58);
}

function test_decode_priv(b58, payload, isTestnet)
{
}

function test_decode_pub(b58, payload, isTestnet, addrType)
{
	var isScript = (addrType == 'script');
	var network = isTestnet ? networks.testnet : networks.livenet;
	var version = isScript ? network.addressScript : network.addressPubkey;
	var buf = new Buffer(payload, 'hex');
	var addr = new Address(b58);

	assert.equal(version, addr.version());
	assert.equal(buf.toString(), addr.payload().toString());
}

function is_valid(datum)
{
	var b58 = datum[0];
	var payload = datum[1];
	var obj = datum[2];
	var isPrivkey = obj['isPrivkey'];
	var isTestnet = obj['isTestnet'];

	if (isPrivkey) {
		test_encode_priv(b58, payload, isTestnet);
		test_decode_priv(b58, payload, isTestnet);
	} else {
		var addrType = obj['addrType'];
		test_encode_pub(b58, payload, isTestnet, addrType);
		test_decode_pub(b58, payload, isTestnet, addrType);
	}
}

function is_invalid(datum)
{
}

var dataValid = JSON.parse(fs.readFileSync('test/base58_keys_valid.json'));
var dataInvalid = JSON.parse(fs.readFileSync('test/base58_keys_invalid.json'));

test('valid', function() {
	dataValid.forEach(function(datum) { is_valid(datum); });
});
{'fraction_non_alphanumeric': 0.15251878652936265, 'fraction_numerical': 0.016142499304202616, 'mean_word_length': 5.768361581920904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2793838', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1239, 'n_words': 272}