Skip to content

Commit b4e1a96

Browse files
committed
merge conflicts in stest
2 parents 42c40c0 + ed640bd commit b4e1a96

11 files changed

Lines changed: 225 additions & 13 deletions

File tree

‎src/main/java/org/tron/core/services/http/solidity/SolidityNodeHttpApiService.java‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public void init() {
115115

116116
@Override
117117
public void init(Args args) {
118+
librustzcashInitZksnarkParams();
118119
}
119120

120121
@Override
@@ -206,4 +207,34 @@ public void stop() {
206207
}
207208
}
208209

210+
private String getParamsFile(String fileName) {
211+
InputStream in = FullNodeHttpApiService.class.getClassLoader()
212+
.getResourceAsStream("params" + File.separator + fileName);
213+
File fileOut = new File(System.getProperty("java.io.tmpdir") + File.separator + fileName);
214+
try {
215+
FileUtils.copyToFile(in, fileOut);
216+
} catch (IOException e) {
217+
logger.error(e.getMessage(), e);
218+
}
219+
return fileOut.getAbsolutePath();
220+
}
221+
222+
private void librustzcashInitZksnarkParams() {
223+
logger.info("init zk param begin");
224+
225+
String spendPath = getParamsFile("sapling-spend.params");
226+
String spendHash = "8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c";
227+
228+
String outputPath = getParamsFile("sapling-output.params");
229+
String outputHash = "657e3d38dbb5cb5e7dd2970e8b03d69b4787dd907285b5a7f0790dcc8072f60bf593b32cc2d1c030e00ff5ae64bf84c5c3beb84ddc841d48264b4a171744d028";
230+
231+
try {
232+
JLibrustzcash.librustzcashInitZksnarkParams(
233+
new InitZksnarkParams(spendPath, spendHash, outputPath, outputHash));
234+
} catch (ZksnarkException e) {
235+
logger.error("librustzcashInitZksnarkParams fail!", e);
236+
}
237+
logger.info("init zk param done");
238+
}
239+
209240
}

‎src/main/java/org/tron/core/zen/ZenTransactionBuilder.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ public SpendDescriptionCapsule generateSpendProof(SpendDescriptionInfo spend,
231231

232232
byte[] voucherPath = spend.voucher.path().encode();
233233

234+
// System.out.println("vocouerPath is: " + ByteArray.toHexString(voucherPath));
235+
// System.out.println("spend is: " + ByteArray.toHexString(spend));
236+
234237
byte[] cv = new byte[32];
235238
byte[] rk = new byte[32];
236239
byte[] zkproof = new byte[192];

‎src/test/java/org/tron/core/actuator/AccountPermissionUpdateActuatorTest.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,9 @@ public void checkAvailableContractTypeCorrespondingToCode() {
11061106
// note: The aim of this test case is to show how the current codes work.
11071107
// The default value is 7fff1fc0037e0000000000000000000000000000000000000000000000000000,
11081108
// and it should call the addSystemContractAndSetPermission to add new contract type
1109+
// When you add a new contact, you can add its to contractType, as '|| contractType = ContractType.XXX',
1110+
// and you will get the value from the output, then update the value to checkAvailableContractType
1111+
// and checkActiveDefaultOperations
11091112
String validContractType = "7fff1fc0037e0800000000000000000000000000000000000000000000000000";
11101113

11111114
byte[] availableContractType = new byte[32];

‎src/test/java/stest/tron/wallet/common/client/utils/PublicMethed.java‎

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.tron.api.GrpcAPI.IvkDecryptParameters;
4646
import org.tron.api.GrpcAPI.Note;
4747
import org.tron.api.GrpcAPI.NoteParameters;
48+
import org.tron.api.GrpcAPI.OvkDecryptParameters;
4849
import org.tron.api.GrpcAPI.PrivateParameters;
4950
import org.tron.api.GrpcAPI.ReceiveNote;
5051
import org.tron.api.GrpcAPI.Return;
@@ -5036,16 +5037,104 @@ public static DecryptNotes listShieldNote(Optional<ShieldAddressInfo> shieldAddr
50365037
WalletGrpc.WalletBlockingStub blockingStubFull) {
50375038
Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build());
50385039
Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber();
5040+
Long startBlockNum = 0L;
5041+
if (currentBlockNum > 100) {
5042+
startBlockNum = currentBlockNum - 100;
5043+
}
5044+
IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder();
5045+
builder.setStartBlockIndex(startBlockNum);
5046+
builder.setEndBlockIndex(currentBlockNum);
5047+
builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk()));
5048+
DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build());
5049+
logger.info(notes.toString());
5050+
return notes;
5051+
}
50395052

5053+
/**
5054+
* constructor.
5055+
*/
5056+
public static DecryptNotes getShieldNotesByIvk(Optional<ShieldAddressInfo> shieldAddressInfo,
5057+
WalletGrpc.WalletBlockingStub blockingStubFull) {
5058+
Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build());
5059+
Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber();
5060+
Long startBlockNum = 0L;
5061+
if (currentBlockNum > 100) {
5062+
startBlockNum = currentBlockNum - 100;
5063+
}
50405064
IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder();
5041-
builder.setStartBlockIndex(currentBlockNum - 100);
5065+
builder.setStartBlockIndex(startBlockNum);
50425066
builder.setEndBlockIndex(currentBlockNum);
50435067
builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk()));
50445068
DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build());
50455069
logger.info(notes.toString());
50465070
return notes;
50475071
}
50485072

5073+
/**
5074+
* constructor.
5075+
*/
5076+
public static DecryptNotes getShieldNotesByIvkOnSolidity(Optional<ShieldAddressInfo> shieldAddressInfo,
5077+
WalletSolidityGrpc
5078+
.WalletSolidityBlockingStub blockingStubSolidity) {
5079+
Block currentBlock = blockingStubSolidity.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build());
5080+
Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber();
5081+
Long startBlockNum = 0L;
5082+
if (currentBlockNum > 100) {
5083+
startBlockNum = currentBlockNum - 100;
5084+
}
5085+
IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder();
5086+
builder.setStartBlockIndex(startBlockNum);
5087+
builder.setEndBlockIndex(currentBlockNum);
5088+
builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk()));
5089+
DecryptNotes notes = blockingStubSolidity.scanNoteByIvk(builder.build());
5090+
logger.info(notes.toString());
5091+
return notes;
5092+
}
5093+
5094+
5095+
5096+
/**
5097+
* constructor.
5098+
*/
5099+
public static DecryptNotes getShieldNotesByOvk(Optional<ShieldAddressInfo> shieldAddressInfo,
5100+
WalletGrpc.WalletBlockingStub blockingStubFull) {
5101+
Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build());
5102+
Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber();
5103+
Long startBlockNum = 0L;
5104+
if (currentBlockNum > 100) {
5105+
startBlockNum = currentBlockNum - 100;
5106+
}
5107+
OvkDecryptParameters.Builder builder = OvkDecryptParameters.newBuilder();
5108+
builder.setStartBlockIndex(startBlockNum);
5109+
builder.setEndBlockIndex(currentBlockNum);
5110+
builder.setOvk(ByteString.copyFrom(shieldAddressInfo.get().getOvk()));
5111+
DecryptNotes notes = blockingStubFull.scanNoteByOvk(builder.build());
5112+
logger.info(notes.toString());
5113+
return notes;
5114+
}
5115+
5116+
/**
5117+
* constructor.
5118+
*/
5119+
public static DecryptNotes getShieldNotesByOvkOnSolidity(Optional<ShieldAddressInfo> shieldAddressInfo,
5120+
WalletSolidityGrpc
5121+
.WalletSolidityBlockingStub blockingStubSolidity) {
5122+
Block currentBlock = blockingStubSolidity.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build());
5123+
Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber();
5124+
Long startBlockNum = 0L;
5125+
if (currentBlockNum > 100) {
5126+
startBlockNum = currentBlockNum - 100;
5127+
}
5128+
OvkDecryptParameters.Builder builder = OvkDecryptParameters.newBuilder();
5129+
builder.setStartBlockIndex(startBlockNum);
5130+
builder.setEndBlockIndex(currentBlockNum);
5131+
builder.setOvk(ByteString.copyFrom(shieldAddressInfo.get().getOvk()));
5132+
DecryptNotes notes = blockingStubSolidity.scanNoteByOvk(builder.build());
5133+
logger.info(notes.toString());
5134+
return notes;
5135+
}
5136+
5137+
50495138
/**
50505139
* constructor.
50515140
*/

src/test/java/stest/tron/wallet/zentoken/WalletTestZenToken001.java renamed to src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken001.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.zentoken;
1+
package stest.tron.wallet.dailybuild.zentoken;
22

33
import com.google.protobuf.ByteString;
44
import io.grpc.ManagedChannel;

src/test/java/stest/tron/wallet/zentoken/WalletTestZenToken002.java renamed to src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken002.java

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.zentoken;
1+
package stest.tron.wallet.dailybuild.zentoken;
22

33
import io.grpc.ManagedChannel;
44
import io.grpc.ManagedChannelBuilder;
@@ -15,6 +15,7 @@
1515
import org.tron.api.GrpcAPI.DecryptNotes;
1616
import org.tron.api.GrpcAPI.Note;
1717
import org.tron.api.WalletGrpc;
18+
import org.tron.api.WalletSolidityGrpc;
1819
import org.tron.common.crypto.ECKey;
1920
import org.tron.common.utils.ByteArray;
2021
import org.tron.common.utils.Utils;
@@ -44,8 +45,12 @@ public class WalletTestZenToken002 {
4445

4546
private ManagedChannel channelFull = null;
4647
private WalletGrpc.WalletBlockingStub blockingStubFull = null;
48+
private ManagedChannel channelSolidity = null;
49+
private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null;
4750
private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list")
4851
.get(0);
52+
private String soliditynode = Configuration.getByPath("testng.conf")
53+
.getStringList("solidityNode.ip.list").get(0);
4954
private String foundationZenTokenKey = Configuration.getByPath("testng.conf")
5055
.getString("defaultParameter.zenTokenOwnerKey");
5156
byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey);
@@ -77,10 +82,14 @@ public void beforeSuite() {
7782
public void beforeClass() {
7883
PublicMethed.printAddress(foundationZenTokenKey);
7984
PublicMethed.printAddress(zenTokenOwnerKey);
80-
channelFull = ManagedChannelBuilder.forTarget(fullnode)
81-
.usePlaintext(true)
85+
channelFull = ManagedChannelBuilder.forTarget(fullnode).usePlaintext(true)
8286
.build();
8387
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
88+
89+
channelSolidity = ManagedChannelBuilder.forTarget(soliditynode)
90+
.usePlaintext(true)
91+
.build();
92+
blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity);
8493
Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId,
8594
costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull));
8695
PublicMethed.waitProduceNextBlock(blockingStubFull);
@@ -122,9 +131,79 @@ public void test1Shield2ShieldTransaction() {
122131
logger.info("Receiver note:" + receiverNote.toString());
123132
Assert.assertTrue(receiverNote.getValue() == sendNote.getValue() - zenTokenFee);
124133

134+
}
135+
136+
/**
137+
* constructor.
138+
*/
139+
@Test(enabled = true, description = "Scan not by ivk and scan not by ivk on FullNode")
140+
public void test2ScanNoteByIvkAndOvk() {
141+
channelSolidity = ManagedChannelBuilder.forTarget(soliditynode)
142+
.usePlaintext(true)
143+
.build();
144+
blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity);
145+
146+
//Scan sender note by ovk equals scan receiver note by ivk on FullNode
147+
Note scanNoteByIvk = PublicMethed
148+
.getShieldNotesByIvk(receiverShieldAddressInfo,blockingStubFull).getNoteTxs(0).getNote();
149+
Note scanNoteByOvk = PublicMethed
150+
.getShieldNotesByOvk(sendShieldAddressInfo,blockingStubFull).getNoteTxs(0).getNote();
151+
Assert.assertEquals(scanNoteByIvk.getValue(),scanNoteByOvk.getValue());
152+
Assert.assertEquals(scanNoteByIvk.getMemo(),scanNoteByOvk.getMemo());
153+
Assert.assertEquals(scanNoteByIvk.getRcm(),scanNoteByOvk.getRcm());
154+
Assert.assertEquals(scanNoteByIvk.getPaymentAddress(),scanNoteByOvk.getPaymentAddress());
155+
}
156+
157+
/**
158+
* constructor.
159+
*/
160+
@Test(enabled = true, description = "Scan not by ivk and scan not by ivk on solidity")
161+
public void test3ScanNoteByIvkAndOvkOnSolidityServer() {
162+
163+
//Scan sender note by ovk equals scan receiver note by ivk in Solidity
164+
PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull,blockingStubSolidity);
165+
Note scanNoteByIvk = PublicMethed
166+
.getShieldNotesByIvkOnSolidity(receiverShieldAddressInfo,blockingStubSolidity)
167+
.getNoteTxs(0).getNote();
168+
Note scanNoteByOvk = PublicMethed
169+
.getShieldNotesByOvkOnSolidity(sendShieldAddressInfo,blockingStubSolidity)
170+
.getNoteTxs(0).getNote();
171+
Assert.assertEquals(scanNoteByIvk.getValue(),scanNoteByOvk.getValue());
172+
Assert.assertEquals(scanNoteByIvk.getMemo(),scanNoteByOvk.getMemo());
173+
Assert.assertEquals(scanNoteByIvk.getRcm(),scanNoteByOvk.getRcm());
174+
Assert.assertEquals(scanNoteByIvk.getPaymentAddress(),scanNoteByOvk.getPaymentAddress());
175+
}
125176

177+
/**
178+
* constructor.
179+
*/
180+
@Test(enabled = true, description = "Scan not by ivk and scan not by ivk on solidity")
181+
public void test4ScanNoteByIvkAndOvkOnSolidityServer() {
182+
soliditynode = Configuration.getByPath("testng.conf")
183+
.getStringList("solidityNode.ip.list").get(1);
184+
channelSolidity = ManagedChannelBuilder.forTarget(soliditynode)
185+
.usePlaintext(true)
186+
.build();
187+
blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity);
188+
189+
190+
//Scan sender note by ovk equals scan receiver note by ivk in Solidity
191+
PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull,blockingStubSolidity);
192+
Note scanNoteByIvk = PublicMethed
193+
.getShieldNotesByIvkOnSolidity(receiverShieldAddressInfo,blockingStubSolidity)
194+
.getNoteTxs(0).getNote();
195+
Note scanNoteByOvk = PublicMethed
196+
.getShieldNotesByOvkOnSolidity(sendShieldAddressInfo,blockingStubSolidity)
197+
.getNoteTxs(0).getNote();
198+
Assert.assertEquals(scanNoteByIvk.getValue(),scanNoteByOvk.getValue());
199+
Assert.assertEquals(scanNoteByIvk.getMemo(),scanNoteByOvk.getMemo());
200+
Assert.assertEquals(scanNoteByIvk.getRcm(),scanNoteByOvk.getRcm());
201+
Assert.assertEquals(scanNoteByIvk.getPaymentAddress(),scanNoteByOvk.getPaymentAddress());
126202
}
127203

204+
205+
206+
128207
/**
129208
* constructor.
130209
*/
@@ -138,5 +217,8 @@ public void shutdown() throws InterruptedException {
138217
if (channelFull != null) {
139218
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);
140219
}
220+
if (channelSolidity != null) {
221+
channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS);
222+
}
141223
}
142224
}

src/test/java/stest/tron/wallet/zentoken/WalletTestZenToken003.java renamed to src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken003.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.zentoken;
1+
package stest.tron.wallet.dailybuild.zentoken;
22

33
import io.grpc.ManagedChannel;
44
import io.grpc.ManagedChannelBuilder;

src/test/java/stest/tron/wallet/zentoken/WalletTestZenToken004.java renamed to src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken004.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.zentoken;
1+
package stest.tron.wallet.dailybuild.zentoken;
22

33
import io.grpc.ManagedChannel;
44
import io.grpc.ManagedChannelBuilder;

src/test/java/stest/tron/wallet/zentoken/WalletTestZenToken005.java renamed to src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken005.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.zentoken;
1+
package stest.tron.wallet.dailybuild.zentoken;
22

33
import io.grpc.ManagedChannel;
44
import io.grpc.ManagedChannelBuilder;

src/test/java/stest/tron/wallet/zentoken/WalletTestZenToken006.java renamed to src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken006.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.zentoken;
1+
package stest.tron.wallet.dailybuild.zentoken;
22

33
import io.grpc.ManagedChannel;
44
import io.grpc.ManagedChannelBuilder;
@@ -152,7 +152,7 @@ public void test3ShieldMemoIs513Char() {
152152
+ "7812345678123456781234567812345678123456781234567812345678123456781234567812345678"
153153
+ "1234567812345678123456781234567812345678123456781234567812345678123456781234567812"
154154
+ "3456781234567812345678123456781234567812345678123456781234567812345678123456781234"
155-
+ "56781234567812345678";
155+
+ "5678123456781234567812345678901234567890-";
156156
shieldOutList.clear();
157157
shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress,
158158
"" + zenTokenFee, memo);
@@ -167,6 +167,7 @@ public void test3ShieldMemoIs513Char() {
167167
note = notes.getNoteTxs(0).getNote();
168168
Long receiverShieldTokenAmount = note.getValue();
169169
Assert.assertEquals(receiverShieldTokenAmount, zenTokenFee);
170+
logger.info(PublicMethed.getMemo(note));
170171
Assert.assertEquals(memo, PublicMethed.getMemo(note));
171172
}
172173

0 commit comments

Comments
 (0)