From 28ea694791c4de21daef308b307b50a17fd0bf3f Mon Sep 17 00:00:00 2001 From: lepipele Date: Fri, 20 Oct 2017 16:49:13 -0500 Subject: [PATCH] Extracting my tests to separate class, adding test for generating ExtPubKey --- BTCPayServer.Tests/UnitTest1.cs | 22 ------------- BTCPayServer.Tests/UnitTestPeusa.cs | 50 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 22 deletions(-) create mode 100644 BTCPayServer.Tests/UnitTestPeusa.cs diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index c4bc49608..ad7fa5847 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -345,27 +345,5 @@ namespace BTCPayServer.Tests } } } - - // NOTE: Unit test that generates temorary checkout Bitpay page - // https://forkbitpay.slack.com/archives/C7M093Z55/p1508293682000217 - //[Fact] - //public void Test() - //{ - // var key = new Key(Encoders.Hex.DecodeData("7b70a06f35562873e3dcb46005ed0fe78e1991ad906e56adaaafa40ba861e056")); - // var url = new Uri("https://test.bitpay.com/"); - // var btcpay = new Bitpay(key, url); - // var invoice = btcpay.CreateInvoice(new Invoice() - // { - - // Price = 5.0, - // Currency = "USD", - // PosData = "posData", - // OrderId = "cdfd8a5f-6928-4c3b-ba9b-ddf438029e73", - // ItemDesc = "Hello from the otherside" - // }, Facade.Merchant); - - // // go to invoice.Url - // Trace.WriteLine(invoice.Url); - //} } } diff --git a/BTCPayServer.Tests/UnitTestPeusa.cs b/BTCPayServer.Tests/UnitTestPeusa.cs new file mode 100644 index 000000000..363f0a3d5 --- /dev/null +++ b/BTCPayServer.Tests/UnitTestPeusa.cs @@ -0,0 +1,50 @@ +using NBitcoin; +using NBitcoin.DataEncoders; +using NBitpayClient; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace BTCPayServer.Tests +{ + // Helper class for testing functionality and generating data needed during coding/debuging + public class UnitTestPeusa + { + // Unit test that generates temorary checkout Bitpay page + // https://forkbitpay.slack.com/archives/C7M093Z55/p1508293682000217 + [Fact] + public void BitpayCheckout() + { + var key = new Key(Encoders.Hex.DecodeData("7b70a06f35562873e3dcb46005ed0fe78e1991ad906e56adaaafa40ba861e056")); + var url = new Uri("https://test.bitpay.com/"); + var btcpay = new Bitpay(key, url); + var invoice = btcpay.CreateInvoice(new Invoice() + { + + Price = 5.0, + Currency = "USD", + PosData = "posData", + OrderId = "cdfd8a5f-6928-4c3b-ba9b-ddf438029e73", + ItemDesc = "Hello from the otherside" + }, Facade.Merchant); + + // go to invoice.Url + Console.WriteLine(invoice.Url); + } + + // Generating Extended public key to use on http://localhost:14142/stores/{storeId} + [Fact] + public void GeneratePubkey() + { + var network = Network.RegTest; + + ExtKey masterKey = new ExtKey(); + Console.WriteLine("Master key : " + masterKey.ToString(network)); + ExtPubKey masterPubKey = masterKey.Neuter(); + + ExtPubKey pubkey = masterPubKey.Derive(0); + Console.WriteLine("PubKey " + 0 + " : " + pubkey.ToString(network)); + } + } +}