本文整理汇总了Java中org.ethereum.vm.program.Stack类的典型用法代码示例。如果您正苦于以下问题:Java Stack类的具体用法?Java Stack怎么用?Java Stack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Stack类属于org.ethereum.vm.program包,在下文中一共展示了Stack类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPush1
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void testPush1() {
Program program = executeCode("PUSH1 0xa0", 1);
Stack stack = program.getStack();
Assert.assertEquals(1, stack.size());
Assert.assertEquals(new DataWord(0xa0), stack.peek());
}
示例2: testAdd
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void testAdd() {
Program program = executeCode("PUSH1 1 PUSH1 2 ADD", 3);
Stack stack = program.getStack();
Assert.assertEquals(1, stack.size());
Assert.assertEquals(new DataWord(3), stack.peek());
}
示例3: testMul
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void testMul() {
Program program = executeCode("PUSH1 3 PUSH1 2 MUL", 3);
Stack stack = program.getStack();
Assert.assertEquals(1, stack.size());
Assert.assertEquals(new DataWord(6), stack.peek());
}
示例4: testSub
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void testSub() {
Program program = executeCode("PUSH1 1 PUSH1 2 SUB", 3);
Stack stack = program.getStack();
Assert.assertEquals(1, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
}
示例5: testJumpSkippingInvalidJump
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void testJumpSkippingInvalidJump() {
Program program = executeCode("PUSH1 0x05 JUMP PUSH1 0xa0 JUMPDEST PUSH1 0x01", 4);
Stack stack = program.getStack();
Assert.assertEquals(1, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
}
示例6: dupnFirstItem
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void dupnFirstItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x00 DUPN", 3);
Stack stack = program.getStack();
Assert.assertEquals(2, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
Assert.assertEquals(new DataWord(1), stack.get(0));
}
示例7: dupnFourthItem
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void dupnFourthItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x03 DUPN", 6);
Stack stack = program.getStack();
Assert.assertEquals(5, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
for (int k = 0; k < 4; k++)
Assert.assertEquals(new DataWord(k + 1), stack.get(k));
}
示例8: dupnTwentiethItem
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void dupnTwentiethItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x05 PUSH1 0x06 PUSH1 0x07 PUSH1 0x08 PUSH1 0x09 PUSH1 0x0a PUSH1 0x0b PUSH1 0x0c PUSH1 0x0d PUSH1 0x0e PUSH1 0x0f PUSH1 0x10 PUSH1 0x11 PUSH1 0x12 PUSH1 0x13 PUSH1 0x14 PUSH1 0x13 DUPN", 22);
Stack stack = program.getStack();
Assert.assertEquals(21, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
for (int k = 0; k < 20; k++)
Assert.assertEquals(new DataWord(k + 1), stack.get(k));
}
示例9: swapnSecondItem
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void swapnSecondItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x00 SWAPN", 4);
Stack stack = program.getStack();
Assert.assertEquals(2, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
Assert.assertEquals(new DataWord(2), stack.get(0));
}
示例10: swapnFourthItem
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void swapnFourthItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x02 SWAPN", 6);
Stack stack = program.getStack();
Assert.assertEquals(4, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
Assert.assertEquals(new DataWord(4), stack.get(0));
Assert.assertEquals(new DataWord(2), stack.get(1));
Assert.assertEquals(new DataWord(3), stack.get(2));
}
示例11: swapnTwentiethItem
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void swapnTwentiethItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x05 PUSH1 0x06 PUSH1 0x07 PUSH1 0x08 PUSH1 0x09 PUSH1 0x0a PUSH1 0x0b PUSH1 0x0c PUSH1 0x0d PUSH1 0x0e PUSH1 0x0f PUSH1 0x10 PUSH1 0x11 PUSH1 0x12 PUSH1 0x13 PUSH1 0x14 PUSH1 0x12 SWAPN", 22);
Stack stack = program.getStack();
Assert.assertEquals(20, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
Assert.assertEquals(new DataWord(20), stack.get(0));
for (int k = 1; k < 19; k++)
Assert.assertEquals(new DataWord(k + 1), stack.get(k));
}
示例12: txindexExecution
import org.ethereum.vm.program.Stack; //导入依赖的package包/类
@Test
public void txindexExecution() {
invoke.setTransactionIndex(new DataWord(42));
Program program = executeCode("TXINDEX", 1);
Stack stack = program.getStack();
Assert.assertEquals(1, stack.size());
Assert.assertEquals(new DataWord(42), stack.peek());
}