Exemplo n.º 1
0
        static async Task Main()
        {
            BinanceDexApi binanceDexApi = new BinanceDexApi(new Http(), "https://testnet-dex.binance.org/api/v1/", "tbnb");

            string      symbol      = "TCAN-014_BNB";
            MarketDepth marketDepth = await binanceDexApi.GetOrderBookAsync(symbol);

            OrderBook orderbook = new OrderBook(symbol, marketDepth.Height, marketDepth.Bids, marketDepth.Asks);

            Print(orderbook, 5);
            MarketDiffWebSocket marketDiff = new MarketDiffWebSocket("wss://testnet-dex.binance.org/api/ws", true);

            marketDiff.OnMarketDiffUpdate += (o, e) =>
            {
                orderbook.Modify(e.EventHeight, e.Bids, e.Asks);
                Print(orderbook, 5);
            };

            marketDiff.Connect();
            marketDiff.Subscribe(symbol);

            await Console.In.ReadLineAsync();

            marketDiff.UnsubscribeAll();
            marketDiff.Dispose();
        }
Exemplo n.º 2
0
        public async Task GetPeersAsync_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            BinanceDexApi unitUnderTest = this.CreateBinanceDexApi();

            // Act
            IEnumerable <Peer> result = await unitUnderTest.GetPeersAsync();

            // Assert
            Assert.Fail();
        }
Exemplo n.º 3
0
        public async Task GetValidatorsAsync_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            BinanceDexApi unitUnderTest = this.CreateBinanceDexApi();

            // Act
            Validators result = await unitUnderTest.GetValidatorsAsync();

            // Assert
            result.ValidatorCollection.Dump();
            result.BlockHeight.Dump();
        }
Exemplo n.º 4
0
        public async Task GetTransactionAsync_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            BinanceDexApi unitUnderTest = this.CreateBinanceDexApi();
            string        transactionId = "";//TODO;

            // Act
            Transaction result = await unitUnderTest.GetTransactionAsync(
                transactionId);

            // Assert
            Assert.Fail();
        }
Exemplo n.º 5
0
        public async Task GetAccountSequenceAsync_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            BinanceDexApi unitUnderTest = this.CreateBinanceDexApi();
            string        address       = "";//TODO;

            // Act
            AccountSequence result = await unitUnderTest.GetAccountSequenceAsync(
                address);

            // Assert
            Assert.Fail();
        }
Exemplo n.º 6
0
        public async Task GetMarketPairsAsync_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            BinanceDexApi unitUnderTest = this.CreateBinanceDexApi();
            int           limit         = 500;
            int           offset        = 0;

            // Act
            MarketPairs result = await unitUnderTest.GetMarketPairsAsync(
                limit,
                offset);

            // Assert
            Assert.Fail();
        }
Exemplo n.º 7
0
        public async Task GetNodeInfoAsync_SendingRequest_ReturnsNodeInfo()
        {
            // Arrange
            BinanceDexApi unitUnderTest = this.CreateBinanceDexApi();
            string        json          = @"{""node_info"":{""id"":""c4d94f29e765ecfe81c940e11c2e997321aa8e0f"",""listen_addr"":""10.203.43.118:27146"",""network"":""Binance-Chain-Nile"",""version"":""0.30.1"",""channels"":""3540202122233038"",""moniker"":""Zugspitze"",""other"":{""amino_version"":"""",""p2p_version"":"""",""consensus_version"":"""",""rpc_version"":"""",""tx_index"":""on"",""rpc_address"":""tcp://0.0.0.0:27147""}},""sync_info"":{""latest_block_hash"":""DC18585214F618159722EEEB51C5973800705A490A4D2EB2F48413EF2B90ED6D"",""latest_app_hash"":""39DB053E04AA1683F9ED832C4EDE65CC35D38BB44E53303ED919F1BFC0C7F08C"",""latest_block_height"":10385258,""latest_block_time"":""2019-04-24T11:02:12.664627443Z"",""catching_up"":false},""validator_info"":{""address"":""91844D296BD8E591448EFC65FD6AD51A888D58FA"",""pub_key"":[200,14,154,190,247,255,67,156,16,198,143,232,241,48,61,237,223,197,39,113,140,59,55,216,186,104,7,68,110,60,130,122],""voting_power"":100000000000}}";
            Node          node          = JsonConvert.DeserializeObject <Node>(json);

            // Act
            Node result = await unitUnderTest.GetNodeInfoAsync();

            // Assert
            Assert.That(node.NodeInfo.Id == result.NodeInfo.Id);
            Assert.That(node.NodeInfo.ListenAddr == result.NodeInfo.ListenAddr);
            Assert.That(node.NodeInfo.Network == result.NodeInfo.Network);
            Assert.That(node.NodeInfo.Version == result.NodeInfo.Version);
            Assert.That(node.Code == result.Code);
            Assert.That(node.Message == result.Message);
        }
Exemplo n.º 8
0
        public async Task GetTimeAsync_SendingRequest_ReturnsTime()
        {
            // Arrange
            BinanceDexApi unitUnderTest = this.CreateBinanceDexApi();
            DateTime      apTime        = DateTime.Parse("2019-04-24T10:28:27Z").ToUniversalTime();
            string        blockTime     = "2019-04-24T10:28:26Z";
            int           code          = 0;
            string        message       = null;

            // Act
            Times result = await unitUnderTest.GetTimeAsync();

            // Assert
            Assert.That(result.ApTime == apTime);
            Assert.That(result.BlockTime == blockTime);
            Assert.That(result.Code == code);
            Assert.That(result.Message == message);
        }