<commit_before>// Copyright 2016 <NAME>. All rights reserved.
// Use of this source code is governed by an Apache License 2.0
// that can be found in the LICENSE file.

package btctimestamper

import (
	"encoding/hex"
	"testing"

	"github.com/stratumn/goprivate/blockchain/btc"
	"github.com/stratumn/goprivate/blockchain/btc/btctesting"
	"github.com/stratumn/goprivate/testutil"
	"github.com/stratumn/goprivate/types"
)

func TestTimestamperNetworkTest3(t *testing.T) {
	ts, err := New(&Config{
		WIF: "924v2d7ryXJjnbwB6M9GsZDEjAkfE9aHeQAG1j8muA4UEjozeAJ",
		Fee: int64(10000),
	})
	if err != nil {
		t.Fatal(err)
	}
	if ts == nil {
		t.Fatal("expected timestamper not to be nil")
	}

	if ts.Network() != btc.NetworkTest3 {
		t.Logf("actual: %s, expected: %s", ts.Network().String(), btc.NetworkTest3.String())
		t.Fatal("unexpected network")
	}
}

func TestTimestamperNetworkMain(t *testing.T) {
	ts, err := New(&Config{
		WIF: "L3Wbnfn57Fc547FLSkm6iCzAaHmLArNUBCYx6q8LdxWoEMoFZmLH",
		Fee: int64(10000),
	})
	if err != nil {
		t.Fatal(err)
	}
	if ts == nil {
		t.Fatal("expected timestamper not to be nil")
	}

	if ts.Network() != btc.NetworkMain {
		t.Logf("actual: %s, expected: %s", ts.Network().String(), btc.NetworkMain.String())
		t.Fatal("unexpected network")
	}
}

func TestTimestamperTimestampHash(t *testing.T) {
	mock := &btctesting.Mock{}
	mock.MockFindUnspent.Fn = func(address160 *types.Bytes20, amount int64) ([]btc.Output, int64, error) {
		TXHex := "0100000001746e5a4154a3f772099c9dbc1837c267d72aeb396fc665b5713568" +
			"633a276051000000008a47304402201c366ec94d73671fd0380b7fb27010301c" +
			"05b15eed299ec4a14344b663a5e91802205d755d7f8e1c0bacf732d83b30bd9e" +
			"fca66ca52c2f6c8a3216e7ee7169807816014104d33318fd473f461a54f3fe2a" +
			"eeeb2ba00be07d578598f36e6612b740720d56b630b5d2bd7b9a57f74ae6439a" +<commit_msg>blockchain: Tweaks<commit_after>// Copyright 2016 Stratumn SAS. All rights reserved.
// Use of this source code is governed by an Apache License 2.0
// that can be found in the LICENSE file.

package btctimestamper

import (
	"encoding/hex"
	"testing"

	"github.com/stratumn/goprivate/blockchain/btc"
	"github.com/stratumn/goprivate/blockchain/btc/btctesting"
	"github.com/stratumn/goprivate/testutil"
	"github.com/stratumn/goprivate/types"
)

func TestTimestamperNetworkTest3(t *testing.T) {
	ts, err := New(&Config{
		WIF: "924v2d7ryXJjnbwB6M9GsZDEjAkfE9aHeQAG1j8muA4UEjozeAJ",
		Fee: int64(10000),
	})
	if err != nil {
		t.Fatal(err)
	}
	if ts == nil {
		t.Fatal("expected timestamper not to be nil")
	}

	if ts.Network() != btc.NetworkTest3 {
		t.Logf("actual: %s, expected: %s", ts.Network(), btc.NetworkTest3)
		t.Fatal("unexpected network")
	}
}

func TestTimestamperNetworkMain(t *testing.T) {
	ts, err := New(&Config{
		WIF: "L3Wbnfn57Fc547FLSkm6iCzAaHmLArNUBCYx6q8LdxWoEMoFZmLH",
		Fee: int64(10000),
	})
	if err != nil {
		t.Fatal(err)
	}
	if ts == nil {
		t.Fatal("expected timestamper not to be nil")
	}

	if ts.Network() != btc.NetworkMain {
		t.Logf("actual: %s, expected: %s", ts.Network(), btc.NetworkMain)
		t.Fatal("unexpected network")
	}
}

func TestTimestamperTimestampHash(t *testing.T) {
	mock := &btctesting.Mock{}
	mock.MockFindUnspent.Fn = func(address160 *types.Bytes20, amount int64) ([]btc.Output, int64, error) {
		TXHex := "0100000001746e5a4154a3f772099c9dbc1837c267d72aeb396fc665b5713568" +
			"633a276051000000008a47304402201c366ec94d73671fd0380b7fb27010301c" +
			"05b15eed299ec4a14344b663a5e91802205d755d7f8e1c0bacf732d83b30bd9e" +
			"fca66ca52c2f6c8a3216e7ee7169807816014104d33318fd473f461a54f3fe2a" +
			"eeeb2ba00be07d578598f36e6612b740720d56b630b5d2bd7b9a57f74ae6439a" +
{'fraction_non_alphanumeric': 0.12750205648478202, 'fraction_numerical': 0.1508088840142583, 'mean_word_length': 5.300518134715026, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '6032437', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1620, 'n_words': 248}