public void RepositoryCanTrackAddresses() { using (var tester = RepositoryTester.Create(true)) { tester.Repository.Track(pubKey); RepositoryCanTrackAddresses(tester); } }
public void RepositoryCanTrackCallbacks() { using (var tester = RepositoryTester.Create(true)) { tester.Repository.AddBlockCallback(new Uri("http://toto/")).GetAwaiter().GetResult(); tester.Repository.AddBlockCallback(new Uri("http://toto1/")).GetAwaiter().GetResult(); var uris = tester.Repository.GetBlockCallbacks().GetAwaiter().GetResult(); Assert.Equal(2, uris.Length); } }
public void CanSerializeKeyPathFast() { using (var tester = RepositoryTester.Create(true)) { var seria = new Serializer(Network.RegTest); var keyInfo = new KeyPathInformation() { DerivationStrategy = DummyPubKey, Feature = DerivationFeature.Change, KeyPath = new KeyPath("0/1"), Redeem = Script.Empty, ScriptPubKey = Script.Empty }; var str = seria.ToString(keyInfo); for (int i = 0; i < 1500; i++) { seria.ToObject <KeyPathInformation>(str); } } }
private static void RepositoryCanTrackAddresses(RepositoryTester tester) { var keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(0).ScriptPubKey); Assert.NotNull(keyInfo); Assert.Equal(new KeyPath("0/0"), keyInfo.KeyPath); Assert.Equal(keyInfo.DerivationStrategy.ToString(), pubKey.ToString()); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(1).ScriptPubKey); Assert.NotNull(keyInfo); Assert.Equal(new KeyPath("0/1"), keyInfo.KeyPath); Assert.Equal(keyInfo.DerivationStrategy.ToString(), pubKey.ToString()); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(29).ScriptPubKey); Assert.NotNull(keyInfo); Assert.Equal(new KeyPath("0/29"), keyInfo.KeyPath); Assert.Equal(keyInfo.DerivationStrategy.ToString(), pubKey.ToString()); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Change).Derive(29).ScriptPubKey); Assert.NotNull(keyInfo); Assert.Equal(new KeyPath("1/29"), keyInfo.KeyPath); Assert.Equal(keyInfo.DerivationStrategy.ToString(), pubKey.ToString()); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(30).ScriptPubKey); Assert.Null(keyInfo); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Change).Derive(30).ScriptPubKey); Assert.Null(keyInfo); tester.Repository.MarkAsUsed(CreateKeyPathInformation(pubKey, new KeyPath("1/5"))); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Change).Derive(25).ScriptPubKey); Assert.NotNull(keyInfo); Assert.Equal(new KeyPath("1/25"), keyInfo.KeyPath); Assert.Equal(keyInfo.DerivationStrategy, pubKey); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Change).Derive(36).ScriptPubKey); Assert.Null(keyInfo); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(30).ScriptPubKey); Assert.Null(keyInfo); for (int i = 0; i < 10; i++) { tester.Repository.MarkAsUsed(CreateKeyPathInformation(pubKey, new KeyPath("1/" + i))); } keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(30).ScriptPubKey); Assert.Null(keyInfo); tester.Repository.MarkAsUsed(CreateKeyPathInformation(pubKey, new KeyPath("1/10"))); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(30).ScriptPubKey); Assert.NotNull(keyInfo); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(39).ScriptPubKey); Assert.NotNull(keyInfo); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Deposit).Derive(41).ScriptPubKey); Assert.Null(keyInfo); //No op tester.Repository.MarkAsUsed(CreateKeyPathInformation(pubKey, new KeyPath("1/6"))); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Change).Derive(29).ScriptPubKey); Assert.NotNull(keyInfo); Assert.Equal(new KeyPath("1/29"), keyInfo.KeyPath); Assert.Equal(keyInfo.DerivationStrategy.ToString(), pubKey.ToString()); keyInfo = tester.Repository.GetKeyInformation(pubKey.GetLineFor(DerivationFeature.Change).Derive(30).ScriptPubKey); Assert.Null(keyInfo); }