@@ -1984,6 +1984,133 @@ await VirtualAddressContractStub.VirtualAddressVote.SendAsync(new VirtualAddress
19841984 return result . ActiveVotingRecords . First ( ) . VoteId ;
19851985 }
19861986
1987+ // [Fact]
1988+ // public async Task<Hash> VirtualAddress_Vote_WithInlineTxIdAndCountTest()
1989+ // {
1990+ // var amount = 100;
1991+ // const int lockTime = 100 * 60 * 60 * 24;
1992+ // var candidatesKeyPairs = await ElectionContract_AnnounceElection_Test();
1993+ // var candidateKeyPair = candidatesKeyPairs[0];
1994+ //
1995+ // var address = await VirtualAddressContractStub.GetVirtualAddress.CallAsync(new Empty());
1996+ // var initBalance = 100000;
1997+ //
1998+ // await TokenContractStub.Transfer.SendAsync(new TransferInput
1999+ // {
2000+ // Amount = initBalance,
2001+ // Symbol = "ELF",
2002+ // To = address,
2003+ // Memo = "test"
2004+ // });
2005+ //
2006+ // CheckBalance(address, "ELF", initBalance);
2007+ // CheckBalance(address, "SHARE", 0);
2008+ // CheckBalance(address, "VOTE", 0);
2009+ //
2010+ // var virtualAddressVoteInput = new VirtualAddressVoteInput
2011+ // {
2012+ // PubKey = candidateKeyPair.PublicKey.ToHex(),
2013+ // Amount = amount,
2014+ // EndTimestamp = TimestampHelper.GetUtcNow().AddSeconds(lockTime),
2015+ // Token = HashHelper.ComputeFrom("token A")
2016+ // };
2017+ //
2018+ // var resultawait = await VirtualAddressContractStub.VirtualAddressVoteWithInline.SendAsync(new VirtualAddressVoteWithCountInput
2019+ // {
2020+ // VoteInput = virtualAddressVoteInput,
2021+ // Count = 6
2022+ // });
2023+ // return null;
2024+ // }
2025+ //
2026+ [ Fact ]
2027+ public async Task < Hash > VirtualAddress_Vote_WithInlineTxIdTest ( )
2028+ {
2029+ var amount = 100 ;
2030+ const int lockTime = 100 * 60 * 60 * 24 ;
2031+ var candidatesKeyPairs = await ElectionContract_AnnounceElection_Test ( ) ;
2032+ var candidateKeyPair = candidatesKeyPairs [ 0 ] ;
2033+
2034+ var address = await VirtualAddressContractStub . GetVirtualAddress . CallAsync ( new Empty ( ) ) ;
2035+ var initBalance = 100000 ;
2036+
2037+ await TokenContractStub . Transfer . SendAsync ( new TransferInput
2038+ {
2039+ Amount = initBalance ,
2040+ Symbol = "ELF" ,
2041+ To = address ,
2042+ Memo = "test"
2043+ } ) ;
2044+
2045+ CheckBalance ( address , "ELF" , initBalance ) ;
2046+ CheckBalance ( address , "SHARE" , 0 ) ;
2047+ CheckBalance ( address , "VOTE" , 0 ) ;
2048+
2049+ var virtualAddressVoteInput = new VirtualAddressVoteInput
2050+ {
2051+ PubKey = candidateKeyPair . PublicKey . ToHex ( ) ,
2052+ Amount = amount ,
2053+ EndTimestamp = TimestampHelper . GetUtcNow ( ) . AddSeconds ( lockTime ) ,
2054+ Token = HashHelper . ComputeFrom ( "token A" )
2055+ } ;
2056+
2057+ await VirtualAddressContractStub . VirtualAddressVoteWithInline . SendAsync ( new VirtualAddressVoteWithCountInput
2058+ {
2059+ VoteInput = virtualAddressVoteInput ,
2060+ Count = 1
2061+ } ) ;
2062+
2063+ var result = await ElectionContractStub . GetElectorVote . CallAsync ( new StringValue
2064+ {
2065+ Value = address . ToBase58 ( )
2066+ } ) ;
2067+ result . ActiveVotedVotesAmount . ShouldBe ( amount ) ;
2068+ result = await ElectionContractStub . GetElectorVoteWithRecords . CallAsync ( new StringValue
2069+ {
2070+ Value = address . ToBase58 ( )
2071+ } ) ;
2072+ result . ActiveVotedVotesAmount . ShouldBe ( amount ) ;
2073+ result = await ElectionContractStub . GetElectorVoteWithAllRecords . CallAsync ( new StringValue
2074+ {
2075+ Value = address . ToBase58 ( )
2076+ } ) ;
2077+ result . AllVotedVotesAmount . ShouldBe ( amount ) ;
2078+
2079+ CheckBalance ( address , "ELF" , initBalance - amount ) ;
2080+ CheckBalance ( address , "SHARE" , amount ) ;
2081+ CheckBalance ( address , "VOTE" , amount ) ;
2082+
2083+ await VirtualAddressContractStub . VirtualAddressVote . SendAsync ( new VirtualAddressVoteInput
2084+ {
2085+ PubKey = candidateKeyPair . PublicKey . ToHex ( ) ,
2086+ Amount = amount ,
2087+ EndTimestamp = TimestampHelper . GetUtcNow ( ) . AddSeconds ( lockTime ) ,
2088+ Token = HashHelper . ComputeFrom ( "token A" )
2089+ } ) ;
2090+
2091+ result = await ElectionContractStub . GetElectorVote . CallAsync ( new StringValue
2092+ {
2093+ Value = address . ToBase58 ( )
2094+ } ) ;
2095+ result . ActiveVotedVotesAmount . ShouldBe ( amount + amount ) ;
2096+ result = await ElectionContractStub . GetElectorVoteWithRecords . CallAsync ( new StringValue
2097+ {
2098+ Value = address . ToBase58 ( )
2099+ } ) ;
2100+ result . ActiveVotedVotesAmount . ShouldBe ( amount + amount ) ;
2101+ result = await ElectionContractStub . GetElectorVoteWithAllRecords . CallAsync ( new StringValue
2102+ {
2103+ Value = address . ToBase58 ( )
2104+ } ) ;
2105+ result . AllVotedVotesAmount . ShouldBe ( amount + amount ) ;
2106+
2107+ CheckBalance ( address , "ELF" , initBalance - amount - amount ) ;
2108+ CheckBalance ( address , "SHARE" , amount + amount ) ;
2109+ CheckBalance ( address , "VOTE" , amount + amount ) ;
2110+
2111+ return result . ActiveVotingRecords . First ( ) . VoteId ;
2112+ }
2113+
19872114 [ Fact ]
19882115 public async Task VirtualAddress_Withdraw_Test ( )
19892116 {
0 commit comments