public void SelectCoinsTest01() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = GetBitcoinUtxoList(); UtxoData[] selectedList = util.SelectCoins(utxos, 0, 0, 20.0); Assert.Empty(selectedList); Assert.Equal(0, util.GetLastSelectedUtxoFee()); }
public void SelectCoinsTest03() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = GetBitcoinUtxoList(); UtxoData[] selectedList = util.SelectCoins(utxos, 1500, 119154360, 20.0); Assert.Single(selectedList); long totalAmount = CoinSelectionUtil.GetTotalAmount(selectedList); Assert.Equal(156250000, totalAmount); if (selectedList.Length == 1) { Assert.Equal(156250000, selectedList[0].GetAmount()); } Assert.Equal(1380, util.GetLastSelectedUtxoFee()); }
public void SelectCoinsTest12() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = GetBitcoinBnbUtxoList(CfdNetworkType.Mainnet); UtxoData[] selectedList = util.SelectCoins(utxos, 1500, 155060800, 2.0, -1, -1, -1); Assert.Single(selectedList); long totalAmount = CoinSelectionUtil.GetTotalAmount(selectedList); Assert.Equal(155062500, totalAmount); if (selectedList.Length == 1) { Assert.Equal(155062500, selectedList[0].GetAmount()); } Assert.Equal(184, util.GetLastSelectedUtxoFee()); }
public void SelectCoinsTest11() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = GetBitcoinBnbUtxoList(CfdNetworkType.Mainnet); UtxoData[] selectedList = util.SelectCoins(utxos, 1500, 99998500, 2.0, -1, -1, -1); Assert.Equal(2, selectedList.Length); long totalAmount = CoinSelectionUtil.GetTotalAmount(selectedList); Assert.Equal(100001090, totalAmount); if (selectedList.Length == 2) { Assert.Equal(85062500, selectedList[0].GetAmount()); Assert.Equal(14938590, selectedList[1].GetAmount()); } Assert.Equal(368, util.GetLastSelectedUtxoFee()); }
public void SelectCoinsTest06() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = GetBitcoinUtxoList(); UtxoData[] selectedList = util.SelectCoins(utxos, 1500, 460000000, 20.0); Assert.Equal(2, selectedList.Length); long totalAmount = CoinSelectionUtil.GetTotalAmount(selectedList); Assert.Equal(468750000, totalAmount); if (selectedList.Length == 2) { Assert.Equal(312500000, selectedList[0].GetAmount()); Assert.Equal(156250000, selectedList[1].GetAmount()); } Assert.Equal(2760, util.GetLastSelectedUtxoFee()); }
public void SelectCoinsTest13() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = GetBitcoinBnbUtxoList(CfdNetworkType.Mainnet); UtxoData[] selectedList = util.SelectCoins(utxos, 1500, 114040000, 1.0, -1, -1, -1); Assert.Equal(3, selectedList.Length); long totalAmount = CoinSelectionUtil.GetTotalAmount(selectedList); Assert.Equal(115063590, totalAmount); if (selectedList.Length == 3) { Assert.Equal(61062500, selectedList[0].GetAmount()); Assert.Equal(39062500, selectedList[1].GetAmount()); Assert.Equal(14938590, selectedList[2].GetAmount()); } Assert.Equal(276, util.GetLastSelectedUtxoFee()); }
public void SelectCoinsErrorTest02() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = GetBitcoinUtxoList(); try { util.SelectCoins(utxos, 1500, 9500000000, 20.0); Assert.True(false); } catch (InvalidOperationException e) { output.WriteLine(e.Message); Assert.Equal("CFD error[IllegalStateError] message:Failed to select coin. Not enough utxos.", e.Message); } catch (Exception except) { output.WriteLine(except.Message); Assert.Equal("", except.Message); } }
public void SelectCoinsErrorTest01() { CoinSelectionUtil util = new CoinSelectionUtil(); UtxoData[] utxos = Array.Empty <UtxoData>(); try { util.SelectCoins(utxos, 1500, 100000000, 20.0); Assert.True(false); } catch (InvalidOperationException e) { output.WriteLine(e.Message); Assert.Equal("utxoList is empty.", e.Message); } catch (Exception except) { output.WriteLine(except.Message); Assert.Equal("", except.Message); } }